ASP:FileUpload.. wont

M

musosdev

Hi guys

This is a repost as I haven't managed to fix the problem yet. I really hope
someone can help as I'm stuck.

I have an asp:fileupload component on a page, and it's giving the following
security exception...

ERROR: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Even though I have again set the Modify and Write permissions for the
NETWORK SERVICE account on the directory.

I've checked the permissions and Network Service has full control. I've also
added every other User in the permissions to full control and that doesn't
help.

Interestingly, if I create a file with System.IO.File.Create()... it works.
With the same path as I'm using in the FileUpload.

Also, I was advised to check the Environment.User variable, but I get the
same security exception when I try to write that out with Response.Write

Please can someone shed any more light on this? Work are pushing for
completion and I have absolutely no idea whats wrong.

Thanks, Dan.
 
J

Joern Schou-Rode

Interestingly, if I create a file with System.IO.File.Create()... it
works. With the same path as I'm using in the FileUpload.

Maybe the permission problem occurs in some temporary system folder - not
in your data folder. When the file is uploaded from the client, it *might*
be that the IIS or the ASP.NET core stores the file in a central location
for you to pick it up. I do not know this.

Some ideas for testing:

1) Is the exception thrown when uploading the file, even if you remove the
part of the code that actually saves the file to your data folder?

2) If no: are you able to loop through the contents of the posted file in
your code, if you do so without storing it on disk first?
 
G

George

Try to give permissions to this folder to following account
1. IIS_WPG

If this does not work try those
ASPNET
IUSR_XXXX
IWAM_XXXXX


George
n

Give permissios to IIS
 

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,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top