Using rewrite in IIS (express) to avoid path-struggle when using Sencha Cmd within ASP.NET MVC

If you’re using Sencha Cmd (you should!) you are aware of the indexHtmlPath-setting in app.json.

In a current project there is a special case feature which requires an execution inside a newly opened window which then has a different url-segment: http://localhost/special-function/ compared to http://localhost/ for the “normal featured” application.

The paths generated by Sencha Cmd and transformed into bootstrap.json are relative ones. So the url aka root of the application matters. But this “feature segment” (that is indeed just a part of the whole application) now leads to 404-responses from IIS Express for bootstrap.json when in development-mode due to the varying paths.

Note: In this project I use Visual Studio to debug and launch the application so there is no embedded jetty (aka sencha app watch) available.

So rewrite comes to the rescue. I use this in my web.config to get this working.

    <rule name="Make Ext JS paths work" stopProcessing="true">
      <match url="special-function/Scripts/myExtApp/(.*)" ignoreCase="true" />
      <action type="Rewrite" url="Scripts/myExtApp/{R:1}" />