I have been using Url.Content inside <% and %> in my views and all seems to be working fine… Then from withing my controller i have tried the following, but it always returns the wrong path
XDocument xdoc = XDocument.Load(Url.Content("~/content/xml/faq.xml"));
and
XDocument xdoc = XDocument.Load(VirtualPathUtility.ToAbsolute("~/content/xml/faq.xml"));
Basically the path shoudl be c:\Vs2008\Source\MyAppName…..
but its returning c:\MyAppName…..
So its invalid,
Any ideas why this is happning?? Is there a work around?
That’s correct. I’m not sure why it’s adding the C:\ but MyApp…\ is the absolute path.
Have you tried Server.MapPath?