Server Error in '/' Application.

Access to the path 'C:\inetpub\wwwroot\testweb.hrsflow.com\Files\ExceptionsLog\20240329_exLog.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:\inetpub\wwwroot\testweb.hrsflow.com\Files\ExceptionsLog\20240329_exLog.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 and IIS 7, and the configured application pool identity on IIS 7.5) 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 access to a file, right-click the file in File 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 33:             try
Line 34:             {
Line 35:                 sw = new StreamWriter(exFile, true, System.Text.Encoding.UTF8);
Line 36:                 sw.WriteLine(string.Format("{0}\r\n\r\nURL: {1}\r\n\r\nMessage: {2}\r\n\r\nStack Trace:\r\n{3}\r\n\r\nInner Ex: {4}\r\n\r\n-------------------\r\n\r\n", DateTime.Now, Request.Url.ToString(), ex.Message, ex.StackTrace, (null != ex.InnerException ? ex.InnerException.Message : "N/A")));
Line 37:             }

Source File: C:\inetpub\wwwroot\testweb.hrsflow.com\_PageStart.cshtml    Line: 35

Stack Trace:


[UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\testweb.hrsflow.com\Files\ExceptionsLog\20240329_exLog.txt' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +721
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1118
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +144
   System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) +133
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) +99
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) +29
   ASP._Page__PageStart_cshtml.Execute() in C:\inetpub\wwwroot\testweb.hrsflow.com\_PageStart.cshtml:35
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +67
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.4087.0