New thread - not same credentials?

C

Casper Hornstrup

I upload an excel file, save it on the webserver and import the contents to
an MSSQL database.
I use the MS JET OleDb provider to read from the excel file. If I do this
during the HTTP
request this works fine. If however I let another thread (from a pool I've
created when
the ASP.NET application was first started) do the job, the OleDb provider
returns E_FAIL.
If I give Everyone full rights on the file, it works when the new thread is
used.
This is on a Windows Server 2003 btw. When the file is uploaded, it receives
Special (Allow List folder / Read data, Allow Delete) for NETWORK SERVICE.
The ASPNET user is not in the ACL. How can I solve this problem?

Casper
 
A

Alvin Bruney

It should not be working for you at all. Well at least, that's the mind set
you should have because you've violated a major thread law here. Threads are
not allowed to tamper with objects belonging to the main thread. The main
thread owns the http object, your worker thread does not. Results will
typically be flakey, working sometimes, failing at others because of the way
requests are scheduled underneath the hood.

To work around this, you can try passing a reference to the http object to
the worker thread. This will allow the worker thread to safely modify the
object and guarantee consitency. So from the pool of threads you created,
let one of the parameters be a httpcontext object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top