Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA 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.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis 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.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating 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.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

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 5 with 1 votes)
Advertisement
More ASP.NET Resources
You can easily retrieve the path to the running ASP.NET application, using Request.PhysicalApplicationPath:

string AppPath = Request.PhysicalApplicationPath;

If the web application is located in C:\Inetpub\wwwroot\WebApplication1, the string AppPath will contain C:\Inetpub\wwwroot\WebApplication1
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by punsisi on Wednesday, December 14th 2005 at 06:05 AM

i want to know how to get the full virtual path to a subdirectory where the ASP.NET web form running.

by PB on Friday, April 14th 2006 at 06:14 AM

Cheers its just what I have been looking for :)

by d on Thursday, June 8th 2006 at 10:45 AM

d

by Jon on Wednesday, August 16th 2006 at 08:10 PM

For Punsisi - The virtual path is Request.ApplicationPath

by matt on Tuesday, September 5th 2006 at 05:51 AM

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?

by matt on Tuesday, September 5th 2006 at 05:56 AM

Actually, forget I spoke, schoolboy error!

Is there a way I can get this from within C# code?

by Josh on Saturday, September 16th 2006 at 09:44 AM

try:
System.Web.HttpContext.Current.Request.ApplicationPath

by Jeff Warner on Monday, December 10th 2007 at 02:40 PM

Server.MapPath("~") works also in C#

by Elia on Friday, September 26th 2008 at 06:01 PM

hi

do someone know how to get from
"Default2.aspx" (in current application)
to
"http://localhost/blablabla/Default2.aspx"

??

by nick on Friday, December 5th 2008 at 06:48 AM

Thank you. Is exactly what I needed. Google indexed this page right.

by mahesh on Wednesday, January 28th 2009 at 05:41 AM

i want to know how to get the full virtual path to a subdirectory where the ASP.NET web form running.

by Roopesh on Tuesday, May 12th 2009 at 06:20 AM

Thanks.. this is the code iam searching for..

by Anil Dwivedi on Saturday, July 18th 2009 at 12:13 AM

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;
}
}

by Kieran on Tuesday, January 12th 2010 at 07:17 AM

Also look at resolveUrl

by Ali on Monday, January 25th 2010 at 07:35 AM

Thanks - was looking for this

by ankush on Thursday, February 4th 2010 at 07:25 AM

Server.MapPath("~") works also in C#

by stillatmylinux on Thursday, March 11th 2010 at 02:31 PM

System.Web.HttpContext.Current.Server.MapPath("~" )

by Rocky on Thursday, April 22nd 2010 at 11:47 AM

Thanks.

by Ryan on Wednesday, June 16th 2010 at 04:25 AM

stillatmylinux YOU ARE LEGEND :)

by Ryan on Wednesday, June 16th 2010 at 04:25 AM

Did I mention ... stillatmylinux ... YOU ARE LEGEND :)

by Julio on Wednesday, November 3rd 2010 at 10:24 PM

I had the same problem, nice solution Anil

by gnanam on Thursday, November 25th 2010 at 07:17 AM


Hai,

It is very help for me.

Thank you.......

by Moussa on Thursday, December 16th 2010 at 11:14 AM

here it is the solution to get the current Execution ASP File Path :

Request.AppRelativeCurrentExecutionFilePath

ex :
Response.Redirect(Request.AppRelativeCurrentExecutionFilePath);

its working .. have fun

by article submission service on Sunday, December 18th 2011 at 12:08 PM

The update somehow monkeyed with the password for the ASPNET user used to run the worker process. I edited machine.config, set the processModel tag's password attribute to password=AutoGenerate. I then saved machine.config, restarted IIS, and ran the application in IE locally as Administrator. This cleared up the problem.


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs ASP.NET Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Ads

From the creators of Geekpedia, a revolutionary new coupon website!

BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.

Coupons
Discover Geekpedia
Other Resources