Path Problems

Discussion in 'ASP .Net' started by Jordan S, Jan 10, 2005.

  1. Jordan S

    Jordan S Guest

    I'm kind of new to all of this Web app development and have developed an
    ASP.NET Web application under the default c:\inetpub\wwwroot\myApp.

    I just went to move it to a hosted site and I'm having all sorts of trouble
    following from the fact that the root in my development is actually *under*
    the Default Web Site's root; whereas the root of the app in the hosted
    environment is just the root, itself.

    While I can go and recode the app so that it works in the hosted
    environment, then it will break in my development machine.

    What to do? I'm sure I'm not the first person to encounter this scenario -
    what do you experts do to have root-relative paths match up between
    development and production?

    Thanks.
     
    Jordan S, Jan 10, 2005
    #1
    1. Advertising

  2. Jordan S

    WJ Guest

    "Jordan S" <> wrote in message
    news:...
    > I'm kind of new to all of this Web app development and have developed an
    > ASP.NET Web application under the default c:\inetpub\wwwroot\myApp.
    >
    > I just went to move it to a hosted site and I'm having all sorts of
    > trouble following from the fact that the root in my development is
    > actually *under* the Default Web Site's root;


    Your applications do not need to be under the default c:\inetpub\wwwroot.
    You can use the IIS/MMC to redirect your site to any folder within your box
    at will. I am using Windows IIS since Windows NT 4.0 and now Server 2003
    Standard and I have my own folder unless you use other webservers to host
    your app.

    > While I can go and recode the app so that it works in the hosted
    > environment, then it will break in my development machine.
    >


    Never need to do this. Just code it and test your app in your Windows Xp PC
    (as an example), once done, deploy it by doing the following:

    > What to do?


    Just copy the needed files to the host where your application is pointed to.
    Tell your web server what is the default page (ie. Default.Aspx or
    ..html...).

    John
     
    WJ, Jan 10, 2005
    #2
    1. Advertising

  3. Jordan S

    Jordan S Guest

    Thanks - so just to clarify, I think I'll be fine if I do the following:
    1. Create any old folder I want (e.g., C:\MyWebApp)
    2. In IIS, make it a Web application (with C:\MyWebApp as the root).
    3. Move all of my application files and folders into it
    4. Fix all the path-specific logic throughout my app.

    Is this something you more experienced developers would do to fix my app? Is
    there an easier/better way?

    Thanks.



    "WJ" <> wrote in message
    news:...
    >
    > "Jordan S" <> wrote in message
    > news:...
    >> I'm kind of new to all of this Web app development and have developed an
    >> ASP.NET Web application under the default c:\inetpub\wwwroot\myApp.
    >>
    >> I just went to move it to a hosted site and I'm having all sorts of
    >> trouble following from the fact that the root in my development is
    >> actually *under* the Default Web Site's root;

    >
    > Your applications do not need to be under the default c:\inetpub\wwwroot.
    > You can use the IIS/MMC to redirect your site to any folder within your
    > box at will. I am using Windows IIS since Windows NT 4.0 and now Server
    > 2003 Standard and I have my own folder unless you use other webservers to
    > host your app.
    >
    >> While I can go and recode the app so that it works in the hosted
    >> environment, then it will break in my development machine.
    >>

    >
    > Never need to do this. Just code it and test your app in your Windows Xp
    > PC (as an example), once done, deploy it by doing the following:
    >
    >> What to do?

    >
    > Just copy the needed files to the host where your application is pointed
    > to. Tell your web server what is the default page (ie. Default.Aspx or
    > .html...).
    >
    > John
    >
    >
     
    Jordan S, Jan 10, 2005
    #3
  4. Don't hardcode paths into your application. Make everything relative and use
    Server.MapPath when you need physical locations.
     
    =?Utf-8?B?U2NvdHQgU2ltb25z?=, Jan 10, 2005
    #4
  5. Jordan S

    WJ Guest

    "Jordan S" <> wrote in message
    news:...
    > Thanks - so just to clarify, I think I'll be fine if I do the following:
    > 1. Create any old folder I want (e.g., C:\MyWebApp)
    > 2. In IIS, make it a Web application (with C:\MyWebApp as the root).
    > 3. Move all of my application files and folders into it


    On top of that, give appropriate access privilege to the web account that
    runs the web site (not web server). Example: If you have a folder that
    accepts user's uploaded files, then make sure to grant write access to the
    appropriate account for that folder.

    > 4. Fix all the path-specific logic throughout my app.
    >

    Sound like you are hard coding stuffs. If so, yes, clean them up, do not
    hard code things such as "c:\sss\somthing.aspx". Example: If you want to
    invoke Page2.aspx from a, say Default.aspx, then in Default.aspx, just say:
    Response.Redirect("Page2.aspx");

    > Is this something you more experienced developers would do to fix my app?
    > Is there an easier/better way?


    You may want to buy a good book about IIS, it is good to know inside out
    although you need not to. This is the function of a web admin. not
    developer.

    John
     
    WJ, Jan 10, 2005
    #5
  6. Jordan S

    Jordan S Guest

    Thank you very much.
    I'm not hard coding anything from the root (nothing like
    C:\SomeFolder\SomeOtherFolder\SomeFile.aspx). Rather I programmatically
    determine the current application's root:
    string m_appRootFolder =
    System.Web.HttpContext.Current.Request.ApplicationPath.ToString();
    and then refer to folders under the root.

    The problem I had was one of really understanding where my application root
    was and the associated issues resulting from using the default XP/Pro
    C:\inetpub\wwwroot\MyApp setup created by VS.NET. Everything's cool when the
    app exists under the current Web site's root - but the production server
    uses the root, itself. When I started this project I didn't think much about
    it. Now I have to (simple, but important).






    "WJ" <> wrote in message
    news:...
    > "Jordan S" <> wrote in message
    > news:...
    >> Thanks - so just to clarify, I think I'll be fine if I do the following:
    >> 1. Create any old folder I want (e.g., C:\MyWebApp)
    >> 2. In IIS, make it a Web application (with C:\MyWebApp as the root).
    >> 3. Move all of my application files and folders into it

    >
    > On top of that, give appropriate access privilege to the web account that
    > runs the web site (not web server). Example: If you have a folder that
    > accepts user's uploaded files, then make sure to grant write access to the
    > appropriate account for that folder.
    >
    >> 4. Fix all the path-specific logic throughout my app.
    >>

    > Sound like you are hard coding stuffs. If so, yes, clean them up, do not
    > hard code things such as "c:\sss\somthing.aspx". Example: If you want to
    > invoke Page2.aspx from a, say Default.aspx, then in Default.aspx, just
    > say: Response.Redirect("Page2.aspx");
    >
    >> Is this something you more experienced developers would do to fix my app?
    >> Is there an easier/better way?

    >
    > You may want to buy a good book about IIS, it is good to know inside out
    > although you need not to. This is the function of a web admin. not
    > developer.
    >
    > John
    >
    >
    >
     
    Jordan S, Jan 10, 2005
    #6
    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. Keith-Earl
    Replies:
    1
    Views:
    2,025
    Peter O'Reilly
    May 3, 2004
  2. Replies:
    0
    Views:
    2,293
  3. Mupota Muchelemba
    Replies:
    1
    Views:
    949
    Tony Morris
    Feb 4, 2004
  4. Matt
    Replies:
    3
    Views:
    19,718
    Sudsy
    Jul 8, 2004
  5. James
    Replies:
    2
    Views:
    13,955
    Andrew Thompson
    Dec 7, 2004
Loading...

Share This Page