[Solved] IIS Error: Access to the path is denied

indradeo
 
on Apr 27, 2021 11:05 PM
7339 Views

Dear Sir,

while i have run mention code in VB 2012 , It,s working fine . But while i have run in IIS i have getting mention error.

Please help to remove same.

In IIS:-

URL :-http://10.1.246.41/CEMS/ReadTxtFile/WebForm2.aspx

Server Error in '/CEMS' Application.


Access to the path '\\10.1.150.248\display board\STACK1UNIT1.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 '\\10.1.150.248\display board\STACK1UNIT1.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 20:         {
Line 21: 
Line 22:             string textFromFile = (new WebClient()).DownloadString("file://10.1.150.248/display%20board/STACK1UNIT1.txt");
Line 23:             lines = textFromFile.Split('\n');
Line 24:             DataTable dt = new DataTable();

Source File: f:\Intranet\mejaitapps\ReadTxtFile\ReadTxtFile\WebForm2.aspx.cs    Line: 22 Stack Trace:

[UnauthorizedAccessException: Access to the path '\\10.1.150.248\display board\STACK1UNIT1.txt' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +12841045
   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) +776
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +60
   System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async) +61
   System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint) +89

[WebException: Access to the path '\\10.1.150.248\display board\STACK1UNIT1.txt' is denied.]
   System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint) +387
   System.Net.FileWebRequest.GetResponseCallback(Object state) +290

[WebException: Access to the path '\\10.1.150.248\display board\STACK1UNIT1.txt' is denied.]
   System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +283
   System.Net.WebClient.DownloadString(Uri address) +100
   System.Net.WebClient.DownloadString(String address) +30
   ReadTxtFile.WebForm2.Page_Load(Object sender, EventArgs e) in f:\Intranet\mejaitapps\ReadTxtFile\ReadTxtFile\WebForm2.aspx.cs:22
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

 


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

Download FREE API for Word, Excel and PDF in ASP.Net: Download