Tuesday, March 4, 2014

TypeScript: Enable sourcemap support for an IIS hosted ASP.NET MVC site

When you are using TypeScript in Visual Studio 2013, a source map is created when your TypeScript is build. This allows you to debug your TypeScript files in the browser. It will map the generated JavaScript to the corresponding lines inside your TypeScript file. 

image

However, this is the theory. When I added some TypeScript files to my MVC application, I couldn’t get it working. When I opened the source files inside the Chrome Developer Tools, the files were empty. image

image

When I took a look at the Netwerk tab, I found the following error:

image

It seems that when you host your project in IIS, the .ts extension is blocked by default. So this explained the 404 error.

The solution was to add the .ts file extension inside the web.config:

3 comments:

Max said...

This was very helpful. Thank you!

C. L. Jones said...

Great stuff, thank you!

HappyJane said...

Thank you very much!