asp:FileUpload permission problem

M

musosdev

Hi guys

I'm having a problem uploading files to 1&1 using the asp:FileUpload control.

Currently, I have direct file writing code (FileStream) working, having set
the permissions on the directory for the NETWORK SERVICE account.

However, the asp:FileUpload still fails with the following error...

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.

How can I get the permissions working for this control?

Thanks,


Dan

VS2005, .net 2.0.50727
 
J

Joern Schou-Rode

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

Just to make sure if the problem is what you think it is, try to grant
"Everyone" full control on the folder where the file should be written. If
this does not help, revoke the setting and start looking for the problem
in some other location. If it works, revoke the setting and investigate
further whether the application actually runs under the "NETWORK SERVICE"
account.
 
M

musosdev

Joern,

I don't actually have access to the "Everyone" permission through my hosts
1&1. I have users... Network Service, an IUSR_xxx account and another user.

I have set all 3 to have Modify and Write permissions, and it hasn't made
any difference.

Any other thoughts?

Thx, Dan
 
J

Joern Schou-Rode

Any other thoughts?

1) Are you absolutely sure that you are trying to write to the correct
folder?

2) What do you get if you do Response.Write(Environment.UserName) ?

3) Are you able to do System.IO.File.Create(path) and create an empty file
in the folder that way?
 
M

musosdev

Hi Joern,

Thanks for the ideas, I've had some interesting results!

1) Yes, double checked this and it's correct.

2) When I try to Response.Write the Environment.User variable, I get the
same security exception as before...

3) This worked! Which is bizare...

My path is as follows "\\_images\\uploads\\", and when using
System.IO.File.Create, I use Server.MapPath.

I also use this with the file upload dialog - do I not need to? I thought
I'd tried it without.

What else could it be? It's interesting that it works with direct file
creation but not with the FileUpload control.

Thanks,


Dan
 

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

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top