Showing posts with label instance. Show all posts
Showing posts with label instance. Show all posts

Thursday, March 29, 2012

Office interop from asp.net (vb) - permissions problem....

Hi,

I am trying to open a word document from an asp.net page but I keep getting
an access denied error when I try to create an instance of the word
applications.

I have created references to the Office 11.0 Object and it imported the
other references (except stdole which I did manually)

I have imported namepsaces:

Imports System.ComponentModel
Imports Microsoft.Office.Interop

The code I am calling is:

Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
oWordDoc = oWordApp.Documents.Open("c:\text.doc")

The error below says I should give access permission to the ASPNET user. But
a) that user does not exist on my machine - I think it is 'Authenticated
user' that I need and b) which file needs to be given permission?!? I have
tried giving this user full control over the entire Office folder (not
something I'd do on a production server), but no go!

Does anyone know which file needs permission? Any other suggestions?

Thanks in advance,

Stuart

================================================== ==================
The error:
Access is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the
boxes for the desired access.No. ASPNET is a restricted account that's somewhat like "guest" account. It
cannot be used to execute anything outside your web process.

Instead, you should try to "impersonate"(Google for this keyword for usage)
a real "user" account, and give the "user" permission to that directory too,
of course.

"Stu" <s.lock@.cergis.com> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
> Hi,
> I am trying to open a word document from an asp.net page but I keep
> getting an access denied error when I try to create an instance of the
> word applications.
> I have created references to the Office 11.0 Object and it imported the
> other references (except stdole which I did manually)
> I have imported namepsaces:
> Imports System.ComponentModel
> Imports Microsoft.Office.Interop
> The code I am calling is:
> Dim oWordApp As Word.Application
> Dim oWordDoc As Word.Document
> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
> The error below says I should give access permission to the ASPNET user.
> But a) that user does not exist on my machine - I think it is
> 'Authenticated user' that I need and b) which file needs to be given
> permission?!? I have tried giving this user full control over the entire
> Office folder (not something I'd do on a production server), but no go!
> Does anyone know which file needs permission? Any other suggestions?
> Thanks in advance,
> Stuart
>
> ================================================== ==================
> The error:
> Access is denied.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.UnauthorizedAccessException: Access is denied.
> ASP.NET is not authorized to access the requested resource. Consider
> granting access rights to the resource to the ASP.NET request identity.
> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
> or Network Service on IIS 6) that is used if the application is not
> impersonating. If the application is impersonating via <identity
> impersonate="true"/>, the identity will be the anonymous user (typically
> IUSR_MACHINENAME) or the authenticated request user.
> To grant ASP.NET write access to a file, right-click the file in Explorer,
> choose "Properties" and select the Security tab. Click "Add" to add the
> appropriate user or group. Highlight the ASP.NET account, and check the
> boxes for the desired access.
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
news:evrIHLRjFHA.3580@.TK2MSFTNGP09.phx.gbl...
> No. ASPNET is a restricted account that's somewhat like "guest" account.
> It cannot be used to execute anything outside your web process.
> Instead, you should try to "impersonate"(Google for this keyword for
> usage) a real "user" account, and give the "user" permission to that
> directory too, of course.
> "Stu" <s.lock@.cergis.com>
> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
>> Hi,
>>
>> I am trying to open a word document from an asp.net page but I keep
>> getting an access denied error when I try to create an instance of the
>> word applications.
>>
>> I have created references to the Office 11.0 Object and it imported the
>> other references (except stdole which I did manually)
>>
>> I have imported namepsaces:
>>
>> Imports System.ComponentModel
>> Imports Microsoft.Office.Interop
>>
>> The code I am calling is:
>>
>> Dim oWordApp As Word.Application
>> Dim oWordDoc As Word.Document
>> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
>> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
>>
>> The error below says I should give access permission to the ASPNET user.
>> But a) that user does not exist on my machine - I think it is
>> 'Authenticated user' that I need and b) which file needs to be given
>> permission?!? I have tried giving this user full control over the entire
>> Office folder (not something I'd do on a production server), but no go!
>>
>> Does anyone know which file needs permission? Any other suggestions?
>>
>> Thanks in advance,
>>
>> Stuart
>>
>>
>> ================================================== ==================
>> The error:
>> Access is denied.
>> Description: An unhandled exception occurred during the execution of the
>> current web request. Please review the stack trace for more information
>> about the error and where it originated in the code.
>>
>> Exception Details: System.UnauthorizedAccessException: Access is denied.
>>
>> ASP.NET is not authorized to access the requested resource. Consider
>> granting access rights to the resource to the ASP.NET request identity.
>> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
>> or Network Service on IIS 6) that is used if the application is not
>> impersonating. If the application is impersonating via <identity
>> impersonate="true"/>, the identity will be the anonymous user (typically
>> IUSR_MACHINENAME) or the authenticated request user.
>>
>> To grant ASP.NET write access to a file, right-click the file in
>> Explorer, choose "Properties" and select the Security tab. Click "Add" to
>> add the appropriate user or group. Highlight the ASP.NET account, and
>> check the boxes for the desired access.
>>
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
news:evrIHLRjFHA.3580@.TK2MSFTNGP09.phx.gbl...
> No. ASPNET is a restricted account that's somewhat like "guest" account.
> It cannot be used to execute anything outside your web process.
> Instead, you should try to "impersonate"(Google for this keyword for
> usage) a real "user" account, and give the "user" permission to that
> directory too, of course.
> "Stu" <s.lock@.cergis.com>
> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
>> Hi,
>>
>> I am trying to open a word document from an asp.net page but I keep
>> getting an access denied error when I try to create an instance of the
>> word applications.
>>
>> I have created references to the Office 11.0 Object and it imported the
>> other references (except stdole which I did manually)
>>
>> I have imported namepsaces:
>>
>> Imports System.ComponentModel
>> Imports Microsoft.Office.Interop
>>
>> The code I am calling is:
>>
>> Dim oWordApp As Word.Application
>> Dim oWordDoc As Word.Document
>> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
>> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
>>
>> The error below says I should give access permission to the ASPNET user.
>> But a) that user does not exist on my machine - I think it is
>> 'Authenticated user' that I need and b) which file needs to be given
>> permission?!? I have tried giving this user full control over the entire
>> Office folder (not something I'd do on a production server), but no go!
>>
>> Does anyone know which file needs permission? Any other suggestions?
>>
>> Thanks in advance,
>>
>> Stuart
>>
>>
>> ================================================== ==================
>> The error:
>> Access is denied.
>> Description: An unhandled exception occurred during the execution of the
>> current web request. Please review the stack trace for more information
>> about the error and where it originated in the code.
>>
>> Exception Details: System.UnauthorizedAccessException: Access is denied.
>>
>> ASP.NET is not authorized to access the requested resource. Consider
>> granting access rights to the resource to the ASP.NET request identity.
>> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
>> or Network Service on IIS 6) that is used if the application is not
>> impersonating. If the application is impersonating via <identity
>> impersonate="true"/>, the identity will be the anonymous user (typically
>> IUSR_MACHINENAME) or the authenticated request user.
>>
>> To grant ASP.NET write access to a file, right-click the file in
>> Explorer, choose "Properties" and select the Security tab. Click "Add" to
>> add the appropriate user or group. Highlight the ASP.NET account, and
>> check the boxes for the desired access.
>>

Off-Page Rendering of Server Controls with events

Hey everyone. I have another problem. I have an aspx web page that
contains an event. When the event is fired it creates an instance of a
server control that contains an event of its own. I would like to be
able to render the contents of the server control (HTML w/ event
JavaScript code) and store it for later use.

My problem lies when I call the MyControl.RenderControl method. It
returns valid HTML but does not contain the event code since the
control has not been added to any page object.

Here is what I have tried:

HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
hForm.Attributes.Add("runat", "server");
hForm.Controls.Add(spWC);

Page p = new Page();
p.Controls.Add(hForm);
p.RenderControl(hWriter); // <-- error here stating that no Response
object available.

I do understand that I am getting a "Response not available" error
because there is no context associated with the newly created page
object. Any ideas as to how I can achieve the results I am looking
for?

-DavidOn Feb 21, 9:15 am, "Bob Jones" <goodold...@.gmail.comwrote:

Quote:

Originally Posted by

Hey everyone. I have another problem. I have an aspx web page that
contains an event. When the event is fired it creates an instance of a
server control that contains an event of its own. I would like to be
able to render the contents of the server control (HTML w/ event
JavaScript code) and store it for later use.
>
My problem lies when I call the MyControl.RenderControl method. It
returns valid HTML but does not contain the event code since the
control has not been added to any page object.
>
Here is what I have tried:
>
HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
hForm.Attributes.Add("runat", "server");
hForm.Controls.Add(spWC);
>
Page p = new Page();
p.Controls.Add(hForm);
p.RenderControl(hWriter); // <-- error here stating that no Response
object available.
>
I do understand that I am getting a "Response not available" error
because there is no context associated with the newly created page
object. Any ideas as to how I can achieve the results I am looking
for?
>
-David


sp, nobody on here has any idea on how to get this working? Or if it's
even possible

Off-Page Rendering of Server Controls with events

Hey everyone. I have another problem. I have an aspx web page that
contains an event. When the event is fired it creates an instance of a
server control that contains an event of its own. I would like to be
able to render the contents of the server control (HTML w/ event
JavaScript code) and store it for later use.
My problem lies when I call the MyControl.RenderControl method. It
returns valid HTML but does not contain the event code since the
control has not been added to any page object.
Here is what I have tried:
HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
hForm.Attributes.Add("runat", "server");
hForm.Controls.Add(spWC);
Page p = new Page();
p.Controls.Add(hForm);
p.RenderControl(hWriter); // <-- error here stating that no Response
object available.
I do understand that I am getting a "Response not available" error
because there is no context associated with the newly created page
object. Any ideas as to how I can achieve the results I am looking
for?
-DavidOn Feb 21, 9:15 am, "Bob Jones" <goodold...@.gmail.com> wrote:
> Hey everyone. I have another problem. I have an aspx web page that
> contains an event. When the event is fired it creates an instance of a
> server control that contains an event of its own. I would like to be
> able to render the contents of the server control (HTML w/ event
> JavaScript code) and store it for later use.
> My problem lies when I call the MyControl.RenderControl method. It
> returns valid HTML but does not contain the event code since the
> control has not been added to any page object.
> Here is what I have tried:
> HtmlForm hForm = new System.Web.UI.HtmlControls.HtmlForm();
> hForm.Attributes.Add("runat", "server");
> hForm.Controls.Add(spWC);
> Page p = new Page();
> p.Controls.Add(hForm);
> p.RenderControl(hWriter); // <-- error here stating that no Response
> object available.
> I do understand that I am getting a "Response not available" error
> because there is no context associated with the newly created page
> object. Any ideas as to how I can achieve the results I am looking
> for?
> -David
sp, nobody on here has any idea on how to get this working? Or if it's
even possible