How can I read the contents of a file in ASP.Net MVC?

Tymnamuby

New Member
I have an ASP.Net MVC controller action that needs to return a json result (it's actually jsonp, but that's not important) that contains the contents of another html file. So basically, I want to do this:\[code\][JsonpFilter]public JsonResult GetHeader(){ var html = System.IO.File.ReadAllText("/htm/external/header.htm"); return Json(new { html = html }, JsonRequestBehavior.AllowGet);}\[/code\]However, it's not finding the right file. It's looking in the C directory (Could not find a part of the path 'C:\htm\external\header.htm'), when I want it to look at the server's root (plus /htm/external, of course).How can I read this file in? It's externally available, so I guess I could make a separate web request for it, but it seems like I should be able to target it directly.
 
Back
Top