I’m sure there’s something blindingly obvious I’m missing here.
I have an ASP.NET MVC2 app with an XML doc at /content/mydoc.xml. I’m trying to load it using XmlTextReader:
XmlTextReader reader = new XmlTextReader("/content/mydoc.xml");
Stepping through, I can see that this is being resolved to file:///C:/content/mydoc.xml
I know I can use Server.MapPath() to get the file path but that seems rather hackish given that the XML doc is available via http.
Is there a way to get XmlTextReader to properly resolve the URL?
How about
Of course, you’ll need an UrlHelper instance to hand to accomplish this (available as the Url field in view and controller).
EDIT
If I know where the file lives I’d prefer to go for it as a file, not with the overhead of HTTP. As such
MapPathseems like a good choice here.