In a normal ASP.NET project I can retrieve the contents of a JSON file in the root of the project like this:
string filePath = HttpContext.Current.Server.MapPath("~/someFile.json"); if (System.IO.File.Exists(filePath)) { string fileData = System.IO.File.ReadAllText(filePath); var abcInstance = JsonConvert.DeserializeObject<List<Abc>>(fileData); }
Unfortunately in an OWIN WebAPI project I've discovered that I don't have access to HttpContext.Current and thus don't have access to "MapPath".
What's a workaround to load and deserialize a JSON file such as I'm trying to do?
Robert