Creating Virtual Directory through C# code RRS feed

  • Question

  • User-792764019 posted


              I am creating a virtual directory programmatically (in C#), when I run the application through Visual Studio(as a administrator), it works well, but when I publish the site, and then while creating virtual directory, it gives permission error like below..

    System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    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.

    I understand its permission issue that we can set in IIS but programmatically how I can set any permission.

    Please give me some idea.



    Tuesday, November 12, 2013 2:26 AM