1

I am using MVC 6 with .NET Core RC2

In my startup.cs I have the following (as most people suggest):

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseDefaultFiles();
    app.UseStaticFiles();
    app.UseMvc();
}

In my wwwroot/web.config file I have:

<configuration>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
    <rewrite>
      <rules>
        <rule name="IndexHomeRule" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/api/" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

My goal is that all non /api urls will be rewritten to index.html for Angularjs to handle the routing with html5mode. The main directory will load index.html but other than that I get 404 errors for every other url. How can I set up rewriting if not through web.config?

The only controller I have right now is api/BuyersController.cs which routes using [Route("api/[controller]")]

Tyler
  • 3,713
  • 6
  • 37
  • 63

1 Answers1

0

The URL rewriting for ASP.NET CORE RC2 through to RTM is currently broken as it exists in your question.

The ASP.NET team is currently working on some middleware as a direct ASP.NET solution to this problem. The github issue tracking this is located below.

https://github.com/aspnet/BasicMiddleware/issues/43

There are some solutions in this other issue thread that could be of help to you in the interim.

https://github.com/aspnet/IISIntegration/issues/192

twilliams
  • 475
  • 1
  • 6
  • 20