access denied error with response.writefile of UNC file in IIS7. Bug?

来源:互联网 发布:翻译课文的软件 编辑:程序博客网 时间:2024/06/05 02:37

probably i'm in the wrong place, but there's not a place.

I'm moving applications from IIS6 to IIS7.5 (win 7 an win server 2008 r2), when 2 applications (with identity impersonate) try to get a file with response.writefile only from a UNC path i'll get "access denied". In IIS6 and Visual Studio Developer Web Server, same code works.

I can save file with FilePath.SaveAs and get name and length with FileInfo, but not download.

After 2 days of nightmares I have tried to change

Response.WriteFile(filePath) 

to

Response.BinaryWrite(File.ReadAllBytes(filePath))

and now work.

My question is: can I have a microsoft developer to sacrificate for my avenge ????? :)

Filed under: Response.Write BinaryWrite IIS7 UNC access denied
  • Re: access denied error with response.writefile of UNC file in IIS7. Bug?

    03-09-2010, 12:37 AM
    Contact
    Answer
    Reply

    Hi,

    I test "Response.WriteFile" with my IIS7.5 server and write the file with UNC path. But I did not get your error. Maybe it is a configuration mistake for you. Here I post my steps for the testing demo.

    Step 1, Add a ASP.NET Website or ASP.NET Web Application, and create an empty page. The markups in "default.aspx" leave it default, the codes in "default.aspx.cs" are wriiten as below.

    Step 2, Modify the web.config for ASP.NET 4.0.


    Step 3, Publish the web application or web site to one directory on your server.

    Step 4, Create a web site and deploy your application there.

    Step 5, Use ASP.NET IIS Registration Tool (Aspnet_regiis.exe), and run this line with it:

                           aspnet_regiis.exe -r

    Step 6, Test your site.

  • 原创粉丝点击