Saturday, 25 February 2012

How to get virtual path of web application ?

Getting the virtual paths local to server using this syntax.
Syntax :

If you want to use from App_Code Class or From BLL you are not allowed to use Page.ResolveURL method.
You can do this with Following syntax.
Syntax :
string url = HttpRuntime.AppDomainAppVirtualPath + "/whatever";

Note: if web application is hosted in a server root folder at that time AppDomainAppVirtualPath returns just "/". If web application is hosted in a non-root folder it returns virtual path of the folder without "/" in the end.

No comments:

Post a Comment