Click to See Complete Forum and Search --> : Access to File


Nate1
06-22-2007, 06:45 PM
How can I grant the ASP Identity Access to write to a File?
I get this Error when I try to write to the File but there is no secuirty tab under the files properties.

Server Error in '/benson/murachs/chapter2/WebApplication1' Application.
--------------------------------------------------------------------------------

Access to the path "C:\Log\Users.txt" is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path "C:\Log\Users.txt" is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 4:
Line 5: Public Shared Sub WriteUser(ByVal User As User)
Line 6: Dim UserStream As New FileStream("C:\Log\Users.txt", _
Line 7: FileMode.Append, FileAccess.Write)
Line 8: Dim UserWriter As New StreamWriter(UserStream)


Source File: C:\Inetpub\wwwroot\benson\murachs\chapter2\WebApplication1\UserIO.vb Line: 6

Stack Trace:


[UnauthorizedAccessException: Access to the path "C:\Log\Users.txt" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +43
WebApplication1.UserIO.WriteUser(User User) in C:\Inetpub\wwwroot\benson\murachs\chapter2\WebApplication1\UserIO.vb:6
WebApplication1.WebForm1.btnRegister_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\benson\murachs\chapter2\WebApplication1\WebForm1.aspx.vb:51
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

Nate1
06-23-2007, 03:28 AM
Just didn't allow network sharing and them to change the file.