Friday, October 28, 2011 - by

add .json handler support in IIS 7

Sometimes we need to create JSON in a text file with extension .json, however by default IIS 7 or any of the IIS are not configure to handle .json extension. So below is a very simple method to do that. You can apply the method on the root of IIS so .json can be handled by every site or virtual folder in the IIS or just to the specific site.

  1. Open IIS Manager
  2. Display properties for the IIS Server
  3. Click MIME Types and then add the JSON extension:
    • File name extension: .json
    • MIME type: application/json
  4. Go back to the properties for IIS Server
  5. Click on Handler Mappings
    • Add a script map
    • Request path: *.json
    • Executable: C:\WINDOWS\system32\inetsrv\asp.dll
    • Name: JSON

24 Comments

  • angelica
    February 13, 2012 at 2:16 am

    How do you do this on a website hosted on GoDaddy?

    • Bilal Niaz
      February 13, 2012 at 8:58 am

      It would be much easier if you ask goDaddy support directly to add .json module for you.

  • Josef
    March 7, 2012 at 5:25 am

    Actually was searching and found this post just a few down on Google.

    For ASP.NET. you can configure it through web.config, which is much easier that getting GoDaddy to change the server’s settings…
    http://help.godaddy.com/article/6286?locale=en

  • Chit Gohil
    May 14, 2012 at 2:41 am

    Hi I was following this but I’m stuck as there is no asp.dll in my c:/windows/system32/inetsrv folder. What am I missing?
    Thanks
    Chit

  • René
    July 9, 2012 at 10:52 am

    Thanks, exactly what i’m searching for…

  • Anil Phoenix
    October 19, 2012 at 6:41 am

    Thank-you SO very much Bilal Niaz for this post. I was almost banging my head against the wall trying to get this done; to get a sencha project up and running! You’re my savior! Thank you once again!

  • JS
    December 13, 2012 at 1:09 am

    Thanks for posting this, Bilal – exactly what I needed.

    @Chit – had the same problem. If you’re using Windows Server 2008 with IIS7 and there’s no asp.dll in the inetsrv folder, the ASP role service isn’t installed. Open Server Manager, and go to Roles. In the Roles window, under Web Server (IIS), click Add Role Services. Find the Web Server\Application Development\ASP checkbox and select it. Click Next, and then click Install.

  • Jesse
    January 3, 2013 at 4:17 pm

    Note that the IANA-registered media type for JSON is “application/json”, not “application/x-javascript”. JSON is not JavaScript, though it is based on a subset of the language.

  • Bilal Niaz
    January 3, 2013 at 6:44 pm

    Thanks Jesse!

  • Manjeet Singh
    March 26, 2013 at 11:02 am

    Thank a ton! it worked.

  • sania
    April 3, 2013 at 8:17 am

    Thank you

  • Tiago
    October 23, 2013 at 11:15 am

    Very good, thanks!

  • Oliver
    January 3, 2014 at 11:31 am

    Thanks – worked a treat…

  • Ryan
    March 1, 2014 at 4:47 pm

    Not sure if this is new since this post but it’s certainly the simplest and most correct way to do this.

    http://support.godaddy.com/help/article/6286/modifying-or-adding-custom-mime-types-to-windows-hosting-accounts?locale=en

  • Anna
    June 3, 2014 at 7:23 am

    Thanks Bilal!
    I followed the steps and put the JSON file in one of the directories in my application, but when I try to get to the file (http://mysite/somedir/file.json) the application still doesn’t seem to know how to handle it, it sends me back to my login.aspx page. Am I missing something? Thanks.

    • Bilal Niaz
      July 1, 2014 at 6:56 pm

      Sorry Anna,

      Hope you already got it sorted but if not sorry for the late response are you using an MVC applicaiton or a Web Form? In Web Form it should be fine not sure about MVC.

  • Polymer – Tips on running “Getting Started Tutorial” on Windows – Michael Sync
    July 8, 2014 at 10:57 am

    […] you want to see the step by step how to add new MIME in IIS then you can refer to this post “add .json handler support in IIS 7“. But for me, I didn’t add the handler for […]

  • Ibo
    August 25, 2014 at 9:44 am

    You do not have to do it on server side. Especially if you can’t access the IIS just do in in your web.config.

  • Balaji
    October 27, 2014 at 8:52 am

    Thanks , IT worked

  • Solution: IIS Can't Serve Certain File Extension #fix #dev #answer | IT Info
    January 29, 2015 at 5:42 am

    […] you also have to add the Mapping Handler, and for that you have to have the Windows Feature called Classic Asp installed in order to handle […]

  • sam
    October 21, 2015 at 12:21 pm

    Thanks It’s work.

  • Gaz
    March 23, 2016 at 2:06 pm

    Being an Apache bloke and new to IIS, I struggled with this – thanks

  • Q
    April 22, 2016 at 1:23 am

    This worked great for Win 7/64 bit. Thx!!

Post Your Comments

Name (required)
Email Address (will not be published) (required)