Adsence750x90

Monday, March 3, 2014

How to Add Json MIME type in IIS 7.5

Today .NET Web Development and Tools group at Microsoft released Customer Tech Preview (CTP2) release of Visual Studio 2013 Update 2 contains a new JSON editor. "New JSON editor features in Visual Studio 2013 Update 2 CTP2"

So I Installed CTP2 updated for my visual studio 2013 to see how JSON template works and all.
{
   "Person":[
      {
         "FirstName":"Raju",
         "LastName":"Melveetilpurayil",
         "Languages":[
            {
               "id":"1",
               "name":"C#"
            },
            {
               "id":"2",
               "name":"Javascript"
            },
            {
               "id":"3",
               "name":"C++"
            }
         ]
      }
   ]
}


It was ok. but when I tried to read my json file from browser (localhost url)  I am started getting some some errors, I knew I got one exception because last day I got my laptop after repair, everything is new and ready for first run, I do not installed IIS on  my machine.

This was the exception 
HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.  Installed IIS 7.5 and Added MIME type for JSON, default there is no JOSN type in IIS 7.5

How To Add MIME Type In IIS 7.5

1: Open IIS  Manager [ in RUN  type inetmgr] press Enter
2: Click on MIME Types

3: Right click and Select Add
DONE, You added MIME type for JSON in IIS.

I ran my JSON file again and still got some other exceptions.  I started goggling, finally I found Solution that we need to give to run JSON
To allow the IIS to serve JSON files, your need to add some configuration in web.config:
<system.webServer>
      <staticContent>
        <mimeMap fileExtension=".json" mimeType="application/json" />
      </staticContent>
</system.webServer>

      
        
      

2 comments:

Anonymous said...

Nice post

Patrice Rolland said...

thanks but it is not working for me mon site