none
File Access denied RRS feed

  • Question

  • Access to the path 'C:\Inetpub\wwwroot\xlsGen\xlsGen\GenSummaryWorksheet.xlsx' 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\xlsGen\xlsGen\GenSummaryWorksheet.xlsx' 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 86:             System.Data.DataTable dt = new System.Data.DataTable();
    Line 87:             string spath = Server.MapPath("/XLSGen/");
    Line 88:             File.Copy(spath + "SummaryWorksheet.xlsx", spath + "GenSummaryWorksheet.xlsx", true);
    Line 89:
    Line 90:             using (SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(spath + "GenSummaryWorksheet.xlsx", true))
     

    Can Any one Help out in this
    Thursday, November 25, 2010 3:09 PM

Answers

  •  Hi VamsiKP,

    Welcome to MSDN forum and I am glad to help with you.

    After reading your post, I know that you can't access the file in the IIS root path without enough privilege. If I have misunderstood you, please let me know.

    As far as I know, you should grant permissions to NETWORK SERVICE user, you can take the

    actions as follows:

    Right click the folder you are going to access the file -> Properties -> Security Tab, then click the add button, and you will see a new pop-up window. Type "Network" and click check name button, then select the Network Services.

     

    In addition, you can take a look at this thread which is similar with your issue:

    http://forums.asp.net/p/1013434/1357558.aspx

    I hope it can help you and feel free to follow up after you have tried the solution.

    Best Regards,

    Bruce Song


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Bruce Song Thursday, December 2, 2010 8:33 AM
    • Marked as answer by VamsiKP Monday, December 6, 2010 8:45 AM
    Monday, November 29, 2010 3:09 AM

All replies

  •  Hi VamsiKP,

    Welcome to MSDN forum and I am glad to help with you.

    After reading your post, I know that you can't access the file in the IIS root path without enough privilege. If I have misunderstood you, please let me know.

    As far as I know, you should grant permissions to NETWORK SERVICE user, you can take the

    actions as follows:

    Right click the folder you are going to access the file -> Properties -> Security Tab, then click the add button, and you will see a new pop-up window. Type "Network" and click check name button, then select the Network Services.

     

    In addition, you can take a look at this thread which is similar with your issue:

    http://forums.asp.net/p/1013434/1357558.aspx

    I hope it can help you and feel free to follow up after you have tried the solution.

    Best Regards,

    Bruce Song


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Bruce Song Thursday, December 2, 2010 8:33 AM
    • Marked as answer by VamsiKP Monday, December 6, 2010 8:45 AM
    Monday, November 29, 2010 3:09 AM
  • Hi Bruce Song,

     

    Thanks a lot for your answer. It was most useful for me.

     

    ===

    Thanks & Regards

    Vamsi

    Monday, December 6, 2010 8:46 AM
  • Hi VamsiKP,

    You are welcome and it's my pleasure to help you.

    Best regards,

    Bruce Song


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, December 6, 2010 9:53 AM