Path Problems

J

Jordan S

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.
 
W

WJ

Jordan S said:
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
 
J

Jordan S

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.
 
G

Guest

Don't hardcode paths into your application. Make everything relative and use
Server.MapPath when you need physical locations.
 
W

WJ

Jordan S said:
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
 
J

Jordan S

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).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top