2
Answers

Please help me on this error in accessing directory file while I'm running my asp.net application (c#)

jess romero

jess romero

14y
2.9k
1
Hi Sir,

Good day!
Im having an error while I'm running my web application (LAN) using the IP ADDRESS, but it was ok in my local host during testing. Please help me on how could I rid of this error and how to access the particular directory. Here's the error below. thanks in advance sir.



Collapse | Copy Code
Server Error in '/Irocweb' Application.
--------------------------------------------------------------------------------

Access to the path '\\10.229.71.88\IROCDIR\WMXMODEM\20110323' 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.229.71.88\IROCDIR\WMXMODEM\20110323' 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 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 45: //string dirFile = @"\\10.229.71.88\IROCDIR\con_d_ConOrd_JL\CLUSTERED\WMXMODEM\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
Line 46: string dirFile = @"\\10.229.71.88\IROCDIR\WMXMODEM\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
Line 47: string[] srchFile = System.IO.Directory.GetFiles(dirFile);
Line 48:
Line 49: //Array.Sort(srchFile);


Source File: c:\inetpub\wwwroot\irocweb\ConOrdJL.aspx.cs Line: 47

Stack Trace:


[UnauthorizedAccessException: Access to the path '\\10.229.71.88\IROCDIR\WMXMODEM\20110323' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7716783
System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) +1923
System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) +37
System.IO.Directory.GetFiles(String path) +14
ConOrdJL.Get_JL_File() in c:\inetpub\wwwroot\irocweb\ConOrdJL.aspx.cs:47
ConOrdJL.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\irocweb\ConOrdJL.aspx.cs:21
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Answers (2)
0
Irfan  Agaria

Irfan Agaria

NA 7 0 18y
Thanks shailesh the program is well now.thanks a lot
0
shailesh raja

shailesh raja

NA 2 0 18y

the following might help.. it's worked for me..

1. Ensure that the instance of the timer class in not declared locally .. say in onstart of a service or main().. You need to have the instance available at all times so that it is not garbage collected.

2. make sure that you catch exceptions in the timer callback function.. ontimer() and supress them.

3. make sure you have no long running operations in the timer callback function. instead you could spawn a new thread which would invoke the function that does the actual task. and that way you are giving back control ASAP to the .NET framework code that triggered the callback .

4. Avoid extremely small values for the time intreval while instantiating the timer class unless you have a good reason to do so.. a timer intreval of a couple of seconds or minute(s) is a safe bet..

Hope this helps...

Shailesh