开发者

Upload images on web hosted MVC 3 application and Impersonation?

开发者 https://www.devze.com 2023-02-28 23:37 出处:网络
I have an MVC 3 application on a web host, and using an input type=file doesn\'t work for uploading images. I get an \"access denied\" error on the folder.

I have an MVC 3 application on a web host, and using an input type=file doesn't work for uploading images. I get an "access denied" error on the folder.

I contacted the support at the web host, and they said I can't use "Network Services" for file uploads, but I have to use "Impersonation". And I got a link to a page from Microsoft about "Impersonation". But since I didn't get much of an explanation, and they're not very good at giving them anyway, I thought I'd probably get a quicker and better answer here:

Is this impersonation actually what I need to enable file uploads on my site? And if so, exactly how is it to be done (I have a hard time decrypting the Microsoft page...)?

Does this actually enable file uploads for开发者_运维百科 all authenticated users? It seems the page from Microsoft is talking about specific users.

Here's the link: http://support.microsoft.com/kb/306158

Any help appreciated!

UPDATE:

I tried setting identity impersonate="true" in my web.config, but got the following error message on the live site instead:

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineOnly' beyond machine.config.

Source Error:

Line 18: <httpRuntime requestValidationMode="2.0" />
Line 19: <!--Set to allow HTML in comment box of CRM--> 
Line 20: <identity impersonate="true" /> 
Line 21: </system.web> 
Line 22: </location>


You probably don't need Impersonation in a publicly facing web site. You may try storing the uploaded files inside the special ~/App_Data folder where the network service should have access. If you want to use some other folder you will need to grant write permissions to the network service account to this folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消