Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We're using the FileUploadControl to browse for and upload an Excel file to a designated folder on the server.

That part is working fine.

When we try to read the contents of the Excel file we get:

MSIL
Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.


I've found lots of questions and answers about 401 errors but none seem to solve our problem.

I had originally assumed the problem was a write problem getting the uploaded file onto the server, but as I say we can see the file uploads just fine.

Any ideas what could be causeing us problems reading the file after it is uploaded?

-Rd
Posted

1 solution

When you upload files using the FileUpload control the actual placement is done
by ASPNET account, typically Network Services. From your expample it
works.
When you try to read the uploaded file a different account is used,
typically IUSR_MachineName. Please make sure that the upload folder
has this account added and the account has Read rights.
 
Share this answer
 
Comments
Richard A. Dalton 11-Oct-10 9:50am    
Hi Ed, thanks for that.
I'm just waiting for a moment of the IIS Gnome's time to check that out.

One thing though. One of the first experiments tried was to get the FileUploadControl to drop the uploaded file directly into the main directory of the Website. And I still got the same issue.
I'm assuming that IUSR_MachineName (or whatever) would have Read access to that folder.
-Rd
Ed Guzman 11-Oct-10 20:27pm    
I agree, this sounds strange. If you tried already place the file onto the root directory it definitely should have the access, but just double check. Let me know if it works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900