Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How to retrieve contents of JSON file with OWIN project?

$
0
0

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


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>