Re: Getting the application path

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




Use a relative path beginning with a tilde and a slash :

The tilde ( ~ ) stands for the application's root directory.

"~/login.aspx" will always refer to a login.aspx located in
the application's root, no matter what the domain name is.

You can use the same reference for subdirectories :

"~/subdir/newpage.aspx" refers to a page named "newpage.aspx"
which is located in the "/subdir" subdirectory of your App.



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Water Cooler v2" <wtr_clr@xxxxxxxxx> wrote in message
news:1127537123.088740.321980@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> How does one get the root of the ASP.NET application. For instance, my
> application is:
>
> http://localhost/MyApplication/login.aspx
>
> Today, it is on a test server, but when I move it to the production
> server, it would become something like:
>
> http://www.foobar.com/MyApplication/login.aspx


>>>From within one of the pages, how do I get the correct path of the
> application so that I don't have to change hard-coded values everytime.
> I need the entire path and not the relative to the page from which I
> query the path.
>


.



Relevant Pages

  • Re: include, relative path
    ... I'm having a stupid problem with the include command. ... I need to connect to the database from the script "check.php", ... Here you tell to go to root, then get one step closer to root and then look for the libraries directory, we could translate this to "Libraries:\". ... One way to get around some troubles are to use symlinks, this way you can have virtual directories which are located in the same relative path from the calling file, but that could be a bit difficult before you have a grasp of how paths works. ...
    (alt.php)
  • Re: include, relative path
    ... success, maybe because of the PHP version... ... This is a subdirectory for the root of the file system, ... directories which are located in the same relative path from the calling ...
    (alt.php)
  • Re: Developing multiple applications
    ... Either develop on a test server so that you can have multiple sites defined ... in IIS and don't have to worry about this, or when you're working on this ... > doesn't refer to the root of the second application, as I would expect, ... > "suffix" which I apply to all links and on the developlement machine is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Its trying to compile my JavaScript?
    ... I'm running from the ASP.NET web server, so the root of the application ... when use just "/" it's mean relative path from the root.. ... JavaScript. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Form Authentication
    ... interpret "~/" as application root. ... "slawek xxxxx" wrote in message ... > I have found a problem with form authentication method that I can't> solve. ... I have to set this path in> web.config and I want to use relative path. ...
    (microsoft.public.dotnet.framework.aspnet)