"~" in Visual Studio and "~" in real IIS

Discussion in 'ASP .Net' started by Alex Maghen, Feb 16, 2008.

  1. Alex Maghen

    Alex Maghen Guest

    I am confused about something: Let's say I have a web application I've
    developed and it's sitting in a directory called "Docroot". In that Docroot
    folder is a Web.config and a Default.aspx.

    Whe I run the application from within Visual Studio (2008), the URL in IE
    when it runs is:
    http://localhost:2635/Docroot/Default.aspx
    with the "Docroot" directory included in the URL.

    But, of course, when I run it in IIS (outside of Visual Studio), the URL of
    the "base" of the application will be
    http://localhost/Default.aspx
    without the "Docroot" directory showing.

    This poses a little problem for me in development:

    Let's say I want to build my application so that I can rewite the URL of the
    site from within the application based on runtime properties. The problem is,
    I don't know how to rebuild the path of "~" because it'll be different if
    it's running in VS as opposed to normally in IIS.

    Is there a way to "know" this in runtime? And why *is* it different anyway?

    Alex
     
    Alex Maghen, Feb 16, 2008
    #1
    1. Advertising

  2. "Alex Maghen" <> wrote in message
    news:...
    >I am confused about something: Let's say I have a web application I've
    > developed and it's sitting in a directory called "Docroot". In that
    > Docroot
    > folder is a Web.config and a Default.aspx.
    >
    > Whe I run the application from within Visual Studio (2008), the URL in IE
    > when it runs is:
    > http://localhost:2635/Docroot/Default.aspx
    > with the "Docroot" directory included in the URL.
    >
    > But, of course, when I run it in IIS (outside of Visual Studio), the URL
    > of
    > the "base" of the application will be
    > http://localhost/Default.aspx
    > without the "Docroot" directory showing.
    >
    > This poses a little problem for me in development:
    >
    > Let's say I want to build my application so that I can rewite the URL of
    > the
    > site from within the application based on runtime properties. The problem
    > is,
    > I don't know how to rebuild the path of "~" because it'll be different if
    > it's running in VS as opposed to normally in IIS.
    >
    > Is there a way to "know" this in runtime? And why *is* it different
    > anyway?
    >
    > Alex


    I'm not sure why it's different, but you can change it in VS by clicking
    your web site in the Solution Explorer then setting the "Virtual Path"
    property in the Properties window (to, say, "/").

    You can also convert the virtual path at runtime using
    Server.MapPath("~/Default.aspx").
     
    Scott Roberts, Feb 16, 2008
    #2
    1. Advertising

  3. Alex Maghen

    Alex Maghen Guest

    Scott -

    Thanks. I didn't know you could change this Virtual Path value in VS. That
    make things a LOT easier.

    Alex

    "Scott Roberts" wrote:

    >
    > "Alex Maghen" <> wrote in message
    > news:...
    > >I am confused about something: Let's say I have a web application I've
    > > developed and it's sitting in a directory called "Docroot". In that
    > > Docroot
    > > folder is a Web.config and a Default.aspx.
    > >
    > > Whe I run the application from within Visual Studio (2008), the URL in IE
    > > when it runs is:
    > > http://localhost:2635/Docroot/Default.aspx
    > > with the "Docroot" directory included in the URL.
    > >
    > > But, of course, when I run it in IIS (outside of Visual Studio), the URL
    > > of
    > > the "base" of the application will be
    > > http://localhost/Default.aspx
    > > without the "Docroot" directory showing.
    > >
    > > This poses a little problem for me in development:
    > >
    > > Let's say I want to build my application so that I can rewite the URL of
    > > the
    > > site from within the application based on runtime properties. The problem
    > > is,
    > > I don't know how to rebuild the path of "~" because it'll be different if
    > > it's running in VS as opposed to normally in IIS.
    > >
    > > Is there a way to "know" this in runtime? And why *is* it different
    > > anyway?
    > >
    > > Alex

    >
    > I'm not sure why it's different, but you can change it in VS by clicking
    > your web site in the Solution Explorer then setting the "Virtual Path"
    > property in the Properties window (to, say, "/").
    >
    > You can also convert the virtual path at runtime using
    > Server.MapPath("~/Default.aspx").
    >
    >
     
    Alex Maghen, Feb 17, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh
    Replies:
    2
    Views:
    555
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. Thirumalai
    Replies:
    0
    Views:
    719
    Thirumalai
    May 22, 2006
  3. rockdale
    Replies:
    1
    Views:
    653
    Juan T. Llibre
    Aug 23, 2006
  4. xman
    Replies:
    0
    Views:
    545
  5. xman
    Replies:
    1
    Views:
    641
    Victor Bazarov
    Aug 17, 2005
Loading...

Share This Page