Angular.js and setting up IIS to recognize JSON
>> Monday, January 9, 2012
Ok, so I've been messing around with Angular.js, so far, a great framework for client-side HTML manipulation. Advantages include separation of concern (with an MVC architecture), and really good testing ease using Jasmine, taking advantage of Dependency injection, and awesome databinding features.
With regards to the Dependency injection, there is a $xhr service (it's a service used to GET data), but when I attempted to use it with IIS 7, no go. Checking IIS under the hood, I found no MIME mapping to .json files, so after some digging on the web, here is how to set it up:
Configure IIS to recognize JSON:
IIS7 configuration to support JSON:
Using IIS manager: clock on IIS server (the main node on the left - where you see the machine name)
- Add ‘json’ MIME Type
- Double click on ‘MIME Types’ icon
- Click ‘Add…’ link (under Actions section on the right side)
- In ‘Add MIME Type’ window type:
File name extension: .json
MIME type: application/json2. Add Script Map Handler for ‘json’ MIME Type
- Click OK, You should see the .json MIME Type added to the list of the MIME Types list.
- Double click on ‘Handler Mappings’ icon
- Click on ‘Add Script Map…’ link (under Actions section on the right side)
- In ‘Add Script Map’ window type:
Request path: *.json
Executable: C:\Windows\System32\inetsrv\asp.dll
Name: JSON
- Click OK (Message box pops up with a message: Do you want to allow this ISAPI extension?...etc ) Click Yes, You should see the .json extension added to the list of the Handler Mappings list

7 comments:
application/json would be a better (or good additional) choice as its used and recognized by many other servers and client libraries/frameworks
Can we mail you a T-shirt? http://goo.gl/D9uOx
Thanks Igor, I've updated, great work over there!
Thanks Mark! I ran into this issue while debating IIS vs node for serving. Due to other issues and this one, I just stuck with node, but this is definitely useful.
And I'm glad I introduced you to Angularjs; I can't get enough of it.
Thanks for this guide. One note with the install of IIS 7.5 I am using. Instead of asp.dll, I had to use C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Post a Comment