Confused by IIS versus VWD 2008 Dev Server and System.Web.HttpRequest.ApplicationPath
Using Visual Web Developer 08 and it's inbuilt Development Server I'm working through a LINQ to XML tutorial in a book.
This line is giving me a problem:
XElement doc = XElement.Load(Request.ApplicationPath + "\\authors.xml");
Request.ApplicationPath retrieves a path "E:/C10_LINQ/authors.xml" which doesn't exist.
I thought it should get something more http-ish like http://localhost/directory/website/authors.xml
I thought this might be due to using the inbuilt server rather than IIS so I installed IIS 5.0 on XP, which opened up a whole new can of worms because I can't get the website to run.
I am thrashing around in the dark with evil thoughts about reinstalling software!
I seek your help and guidance thanks.
i think you want the RequestUri property, not application path
Of course, thank you!
Got it to work firstly by calming down : ) reading the rest of the chapter properly and creating the XML file in the directory on my hard drive pointed to by Request.ApplicationPath.
Then following your suggestion:
XElement doc = XElement.Load(Request.Url.AbsoluteUri.Replace("tutorial.aspx", "Authors.xml");
fudged it nicely.
And I didn't reinstall anything lol
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)