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.
Thanks
VD
Don't forget to mark this post as "Answer", if it helped you.
Member
24 Points
96 Posts
Creating Virtual Directory through C# code
Nov 12, 2013 02:26 AM|vdtrip|LINK
Hi,
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.
Thanks
VD
All-Star
23975 Points
4084 Posts
Re: Creating Virtual Directory through C# code
Nov 13, 2013 01:57 AM|Starain chen - MSFT|LINK
Hi vdtrip,
Thanks for your post!
In my opinion, you should change the Identity for the Application pool (I test it using the LocalSystem). For more information, please refer to: http://technet.microsoft.com/en-us/library/cc771170%28WS.10%29.aspx
There is a related thread that can help you:
http://forums.iis.net/t/1185764.aspx
Thanks
Best Regards