In my ASP.NET MVC 4 project, I have a
file in my
folder containing geographical data that I want to load up into D3.js.
file directly from the App_Data folder instead.
I tried grabbing the .json's relative path using
var url = "@Url.Content("~/App_Data/example.json")";
I also tried throwing the file into the Content folder to see if the directory name makes a difference.
var path = "@Url.Content("~/Content/example.json")";
NetworkError: 404 Not Found - localhost:xxxxx/Content/u.json
var path = @Url.Content("~/Content/example.json");
SyntaxError: invalid regular expression flag u: var path = /Content/example.json;
appears to send a request to the correct directory, but returns a 404 error. Additionally, using Razor syntax to point to the relative URL works, but still 404s.
var json = $.getJSON("../Content/example.json")
- Adding mimeMap info to web.config also didn't help.
My question is: is it possible to work with a JSON file stored in
directory), using only
way to do this? Is there a better approach to take altogether?