-
Thread, TextWriter and IIS
Hi,
I'm unable to create and write into a text file. Here is the details:
In asp.net application running on IIS 5.0, a text file is getting created
and messages are logged into it using text writer. This happens without any
problem. However, in a process that runs in separate thead, the same code
is not able to log anything and generates the exception 'unauthorised access
exception'. This too, works just fine in the development server but not on
the server maintained by ASP. Anything to be configured anywhere so that
all thread can log using text writer? Any other workaround?
Highly appreciate your help.
Mayank Vyas.
-
Re: Thread, TextWriter and IIS
It's most likely because your hosting provider has configured ASP.NET in IIS5
very securely. When you spin off the thread, it is most likely running as
the ASPNET user with lesser permissions. This behaviour is due to how Microsoft
decided to implement ASP.NET for IIS5. This changes quite a bit in IIS6.
In IIS 5.0, one way that it can be configured to work is: the service that
handles ASP.NET calls runs as the ASPNET user but when your application runs,
that process impersonates your accounts user. Then you create the thread
but it gets created with the parent process' token, which is running as ASPNET.
Your thread then gets ASPNET privledges, which is very little.
A work around might be to pass a reference to the Text Writer to your thread
and allow it to continue writing. This could be a bad idea unless that thread
will be the only thread writing to the file. An other idea could be creating
a function in the parent process that is thread-safe and passing a reference
of the parent class to the thread so that the new thread can call the function
as a method of the parent class. If you need an example, contact me directly
and I'm sure I could whip something up for you.
Good luck!
Matt
"Mayank" <vyasmayank@hotmail.com> wrote:
>
>Hi,
>
>I'm unable to create and write into a text file. Here is the details:
>
>In asp.net application running on IIS 5.0, a text file is getting created
>and messages are logged into it using text writer. This happens without
any
>problem. However, in a process that runs in separate thead, the same code
>is not able to log anything and generates the exception 'unauthorised access
>exception'. This too, works just fine in the development server but not
on
>the server maintained by ASP. Anything to be configured anywhere so that
>all thread can log using text writer? Any other workaround?
>
>Highly appreciate your help.
>
>Mayank Vyas.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks