| |
Filed under: Response.Write BinaryWrite IIS7 UNC access denied
|
-
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>
<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.
Jerry Weng - MSFT
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Microsoft One Code Framework