A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Get the path of the ASP.NET web application that is currently running |
On Monday, June 20th 2005 at 03:49 AM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 0 with 0 votes) |
||
You can easily retrieve the path to the running ASP.NET application, using Request.PhysicalApplicationPath:
If the web application is located in C:\Inetpub\wwwroot\WebApplication1, the string AppPath will contain C:\Inetpub\wwwroot\WebApplication1 |
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current Commentsi want to know how to get the full virtual path to a subdirectory where the ASP.NET web form running.
Cheers its just what I have been looking for :)
d
For Punsisi - The virtual path is Request.ApplicationPath
This seems to be giving me
"C:\WINDOWS\system32"
under IIS and
"C:\Documents and Settings\myname\My Documents\Visual Studio 2005\Projects"
using the ASP development server?
Actually, forget I spoke, schoolboy error!
Is there a way I can get this from within C# code?
try:
System.Web.HttpContext.Current.Request.ApplicationPath
Server.MapPath("~") works also in C#
hi
do someone know how to get from
"Default2.aspx" (in current application)
to
"http://localhost/blablabla/Default2.aspx"
??
Thank you. Is exactly what I needed. Google indexed this page right.
i want to know how to get the full virtual path to a subdirectory where the ASP.NET web form running.
Thanks.. this is the code iam searching for..
The following sample code snippet is used for get the fully qualified web application virtual path of the current website.
For example., http://servername/virtualdir.
This sample property is using "HttpContext" class to get the application path.
public string FullyQualifiedApplicationPath
{
get
{
//Return variable declaration
string appPath = null;
//Getting the current context of HTTP request
HttpContext context = HttpContext.Current;
//Checking the current context content
if (context != null)
{
//Formatting the fully qualified website url/name
appPath = string.Format("{0}://{1}{2}{3}",
context.Request.Url.Scheme,
context.Request.Url.Host,
context.Request.Url.Port == 80 ? string.Empty : ":" context.Request.Url.Port,
context.Request.ApplicationPath);
}
return appPath;
}
}
Also look at resolveUrl
Thanks - was looking for this
Server.MapPath("~") works also in C#
System.Web.HttpContext.Current.Server.MapPath("~" )
Thanks.
stillatmylinux YOU ARE LEGEND :)
Did I mention ... stillatmylinux ... YOU ARE LEGEND :)
Related Knowledge Base Articles
Related Source Code
Related Tutorials
ASP.NET Job Search