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 ????? :)
Re: access denied error with response.writefile of UNC file in IIS7. Bug?
- 28,227 point All-Star
- Jerry Weng - MSFT
- Member since 10-26-2009, 2:14 AM
- Shanghai
- Posts 3,446
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.
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.WriteFile("////jerrywengpc//TDdownload//abc.txt");
- }
- }
Step 2, Modify the web.config for ASP.NET 4.0.
- <configuration>
- <connectionStrings />
- <system.web>
- <compilation debug="true" targetFramework="4.0" />
- <authentication mode="Windows">
- </authentication>
- <pages controlRenderingCompatibilityVersion="3.5"></pages>
- <customErrors mode="Off"/>
- </system.web>
- <system.webServer>
- </system.webServer>
- </configuration>
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.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Microsoft One Code Framework
- access denied error with response.writefile of UNC file in IIS7. Bug?
- Error 1044 in MySQL: Access denied when using LOCK TABLES
- access denied error
- Error---Access is denied
- Access denied error by access to a txt file on the sharepoint server
- SetWindowHookEx API with WH_JOURNALRECORD. This API fails with access denied (Error 5).
- adpatch failed with error: "Missing file format id in file"
- Bug 11775332 - cluvfy fails with PRVF-5636 with DNS response timeout error [ID 11775332.8]
- Error creating bean with name '/in' defined in file解决办法
- ERROR 1045 (28000)- Access denied for user 'xxx'@'localhost' (using password- YES)【奇葩的bug】
- Server Error in '/' Application. Access to the Path Is Denied" error message appears
- Server Error in '/' Application. Access to the Path Is Denied" error message appears
- Error of Access to Azure blob storage with asp.net
- Parse error: syntax error, unexpected end of file in
- Unable to open the physical file "d:\***.mdf". Operating system error 5: "5(Access is denied.)".
- mysql GRANT with ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO
- Error: File not access
- JQuery file upload Access is denied in IE 7, 8, 9
- cross apply 和 outer apply
- rails 下使用juggernaut 即时聊天插件
- nosql 数据库笔记
- Silverlight+WCF 新手实例 象棋 棋子移动-规则[兵、车](七)
- 编译kernel时出现的.config问题!
- access denied error with response.writefile of UNC file in IIS7. Bug?
- Silverlight+WCF 新手实例 象棋 棋子移动-规则[将、马、士、相、炮](八)
- 申通快递一点小事
- datalist 分页
- datalist 分页
- C#在设计时不执行
- 查看oracle连接数
- JSP重复提交解决方法
- datalist 分页