473,511 Members | 10,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Local Dir

How can I get the path of the virtual directory which an ASP.NET app is
running?

For example, on a page running at
http://localhost/myapp/someFolder/default.aspx, I want to extract JUST the
http://localhost/myapp/

what combination of Page.Requests does this?

thnx
Nov 18 '05 #1
3 1183
Hey,

Request.ApplicationPath will get you the virtual directory for the app.
Server.MapPath will get you the physical path

Response.Write(Request.ApplicationPath);
will return
/CodePlay
which is the actual virtual dir for my web app.
and
Response.Write(Server.MapPath(Request.ApplicationP ath));
will return
c:\inetpub\wwwroot\CodePlay
which is also correct physical path on hdd

Chao,

Hermit Dave

"Ryan Moore" <ry*******@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
How can I get the path of the virtual directory which an ASP.NET app is
running?

For example, on a page running at
http://localhost/myapp/someFolder/default.aspx, I want to extract JUST the
http://localhost/myapp/

what combination of Page.Requests does this?

thnx

Nov 18 '05 #2
But what about

http://localhost/codeplay ???

thnx

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Hey,

Request.ApplicationPath will get you the virtual directory for the app.
Server.MapPath will get you the physical path

Response.Write(Request.ApplicationPath);
will return
/CodePlay
which is the actual virtual dir for my web app.
and
Response.Write(Server.MapPath(Request.ApplicationP ath));
will return
c:\inetpub\wwwroot\CodePlay
which is also correct physical path on hdd

Chao,

Hermit Dave

"Ryan Moore" <ry*******@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
How can I get the path of the virtual directory which an ASP.NET app is
running?

For example, on a page running at
http://localhost/myapp/someFolder/default.aspx, I want to extract JUST the http://localhost/myapp/

what combination of Page.Requests does this?

thnx


Nov 18 '05 #3
how bout
Response.Write(Request.Url.Scheme + "://" + Request.Url.Host +
Request.ApplicationPath);

That should sort you out....

Hermit Dave

"Ryan Moore" <ry*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
But what about

http://localhost/codeplay ???

thnx

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OC**************@TK2MSFTNGP10.phx.gbl...
Hey,

Request.ApplicationPath will get you the virtual directory for the app.
Server.MapPath will get you the physical path

Response.Write(Request.ApplicationPath);
will return
/CodePlay
which is the actual virtual dir for my web app.
and
Response.Write(Server.MapPath(Request.ApplicationP ath));
will return
c:\inetpub\wwwroot\CodePlay
which is also correct physical path on hdd

Chao,

Hermit Dave

"Ryan Moore" <ry*******@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
How can I get the path of the virtual directory which an ASP.NET app is running?

For example, on a page running at
http://localhost/myapp/someFolder/default.aspx, I want to extract JUST the http://localhost/myapp/

what combination of Page.Requests does this?

thnx



Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8578
by: Steffen | last post by:
Hi! I'm trying to access a EntityBean from a servlet via the bean's local home interface. The EJB and the Servlet are together in one .ear file and I'm using JBoss 3.2.3. I think the...
0
2395
by: Bill Hernandez | last post by:
Hi, I've been writing software on the mac since 1987, but am brand new at unix/php/mysql, and that's where I'm headed so I'm reading everything I can get my hands on, but like anything else...
1
121507
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
0
1647
by: Jan | last post by:
While building PHP 4.4.0 on a fresh installed FreeBSD 5.4 I get the following error: www# /bin/sh /usr/home/c/console/toolscon/web/2/php-4.4.0/libtool --silent --preserve-dup-deps...
9
2186
by: Stefan Turalski \(stic\) | last post by:
Hi, I done sth like this: for(int i=0; i<10; i++) {...} and after this local declaration of i variable I try to inicialize int i=0;
23
3962
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
6
3612
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
1
6120
by: orp | last post by:
We've been struggling on how to determine if a local user is already in a local group. We have code (C#) that creates a local user, if the user doesn't already exist. And, we have code (C#) that...
55
6151
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
28
2529
by: cpluslearn | last post by:
Hi, I have a local class inside a function template. I am able to wrap any type in my local class. Is it legal C++? What type of class is Local? Is it a class template or regular class? Thanks...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.