Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the physical App root on server? 2

Status
Not open for further replies.

dalchri

Programmer
Apr 19, 2002
608
US
I am trying to load an XML file in my global.asax file:
[tt]
dataset.ReadXML(Server.MapPath(".") & "\MyFile.XML")
[/tt]
The problem is that the path Server.MapPath returns is relative to the page that jump starts the entire web application. For example, the used could hit any number of different pages the first time in my directory structure.

What I need is some way to get the Application root = the physical folder that is mapped to the virtual folder in IIS for the web app.

Is Server.MapPath the wrong thing for this?

I also tried using that thing you use in a windows application to get the full name and path of the assembly running the application but all I got was the path and name of the IIS executable, not the web app.
 
Try using 'Request.PhysicalApplicationPath'.

Hope this helps. NetAngel
 
Sounds like a good use of the web.config file and a hardcoded path in there...

penny1.gif
penny1.gif
 
NetAngel,

Unfortunately, the request object is not available from the Global.asax file. Its a shame because that's exactly what I was after.

Looks like I will have to hard code the path in Web.config. That's a shame because I didn't want to have to change anything between my test site on my box and the deployed application on the web server.

Thanks for the advice both of you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top