Skip to content

Instantly share code, notes, and snippets.

@emyann
Last active August 21, 2017 17:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save emyann/da7361218f26d39de9a5 to your computer and use it in GitHub Desktop.
Save emyann/da7361218f26d39de9a5 to your computer and use it in GitHub Desktop.
ASP.NET web.config configuration for Single Page Application (AngularJS) running on IIS with OwinHttpHandler
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(scripts)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(styles)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(maps)" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(assets)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<handlers>
<remove name="StaticFile"/>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="Owin" verb="" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb"/>
</handlers>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment