I have JSON file in my application and I am tying to access the data in it using Java script.
NOTE: I am not looking for loading JSON file using Ajax call.
Json file Name: PhotoDatabase.json
Json content:
var photosdatabase =
{
"photos":
[
{
"photo_id": 27932,
"photo_title": "Atardecer en Embalse",
"photo_url": "http://www.panoramio.com/photo/27932",
"photo_file_url": "http://mw2.google.com/mw-panoramio/photos/medium/27932.jpg",
"longitude": -64.404945,
"latitude": -32.202924,
},....
]
}
HTML call of JSON file:
<script type="application/json" src="~/PhotosDatabase.json"></script>
Java Script access to json file:
pics = photosdatabase.photos;
The same works in local Java script files but not working in MVC.
In browser sources the JSON file is not loaded.
Should I add some permissions to make the JSON file load into browser?
What I have tried:
I tried to add this to my web config file
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
This didn't work. More over it messed up all and nothing loaded like content files and script files and loaded just text.