New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: URL Rewrite using web.config is broken in RC2 #192

Closed
anwalkers opened this Issue May 25, 2016 · 37 comments

Comments

Projects
None yet
@anwalkers

anwalkers commented May 25, 2016

I have tried moving the web.config to and fro and cannot get the URL rewrite to work in IIS Express from Visual Studio 2015. If there was middleware to perform what is spelled out in the web.config snippet I could punt on the web.config and selfhost. Maybe someone can point me in that direction to solve our problem.

We need to use Angular 1.x HTML 5 routing in our application and this is how we had solved it in RC1 but it doesn't work in RC2. Others are having trouble as well: http://stackoverflow.com/questions/37304113/url-rewriting-in-asp-net-core-rc2#

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    <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" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
@guardrex

This comment has been minimized.

Show comment
Hide comment
@guardrex

guardrex May 25, 2016

Contributor

I'm going to ping @ciel on Slack, who may have a solution for this.

Contributor

guardrex commented May 25, 2016

I'm going to ping @ciel on Slack, who may have a solution for this.

@ciel

This comment has been minimized.

Show comment
Hide comment
@ciel

ciel May 25, 2016

I'll take a look at this when I get home this evening, sure. I'm using
angular extensively with RC2. I know I've got a working demo of this in one
of my projects somewhere.
On May 25, 2016 11:13 AM, "Luke Latham" notifications@github.com wrote:

I'm going to ping @ciel https://github.com/Ciel on Slack, who may have
a solution for this.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#192 (comment)

ciel commented May 25, 2016

I'll take a look at this when I get home this evening, sure. I'm using
angular extensively with RC2. I know I've got a working demo of this in one
of my projects somewhere.
On May 25, 2016 11:13 AM, "Luke Latham" notifications@github.com wrote:

I'm going to ping @ciel https://github.com/Ciel on Slack, who may have
a solution for this.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#192 (comment)

@ciel

This comment has been minimized.

Show comment
Hide comment
@ciel

ciel May 25, 2016

I'm not at a computer right now, but looking at your sample have you tried using "^(.*)$" as the match url? And of course, you can confirm that you've got html5mode active?

ciel commented May 25, 2016

I'm not at a computer right now, but looking at your sample have you tried using "^(.*)$" as the match url? And of course, you can confirm that you've got html5mode active?

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers May 25, 2016

I haven't tried the regex "^(.*)$". Any links to your examples would be great!

anwalkers commented May 25, 2016

I haven't tried the regex "^(.*)$". Any links to your examples would be great!

@muratg

This comment has been minimized.

Show comment
Hide comment
@muratg

muratg May 26, 2016

Member

@anwalkers Were you able to verify the regex suggested by @ciel?

Member

muratg commented May 26, 2016

@anwalkers Were you able to verify the regex suggested by @ciel?

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers May 26, 2016

@muratg I have not. I am on a deadline and have turned HTML5 routing off temporarily. Will tackle this when I get to the Azure WebApp deployment step. Hoping @ciel will have a link to an example along the way.

That said, any progress on getting IIS Express from VS 2015 to pay attention to URL rewriting in the web.config?

anwalkers commented May 26, 2016

@muratg I have not. I am on a deadline and have turned HTML5 routing off temporarily. Will tackle this when I get to the Azure WebApp deployment step. Hoping @ciel will have a link to an example along the way.

That said, any progress on getting IIS Express from VS 2015 to pay attention to URL rewriting in the web.config?

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers May 27, 2016

I tried the following code in my Startup.cs to do middleware URL rewrite. It works fine for the base URL, but does not support deep links into an AngularJS 1.x application with HTML5 routing enabled. It does work with HTML5 routing disabled.

Works:
Base URL: http://localhost:5000
API: http://localhost:5000/api/someApi
Library or resource: http://localhost:5000/lib/library.js
HTML5 Routing Disabled: http://localhost:5000/#/angularRoute NOTE: Deep linking works here.

Does not work:
HTML5 Routing Enabled: http://localhost:5000/angularRoute NOTE: This does work if you have loaded the application from the base URL and navigated to the route, but does not work if you have pasted the deep link with the angular route, http://localhost:5000/angularRoute, into a new browser window.

From Startup.cs:

            app.UseMvc();

            // this serves "index.html" from the wwwroot folder when 
            // a route not containing a file extension is not handled by MVC.
            app.MapWhen(context =>
            {
                var path = context.Request.Path.Value.ToLower();
                return path.Contains(".*");
            },
                branch =>
                {
                    branch.Use((context, next) =>
                    {
                        context.Request.Path = new PathString("/index.html");
                        return next();
                    });

                    branch.UseStaticFiles();
                });

Just for clarity, here is a snippet for enabling HTML5 routing in angular 1.x application. It removes the # hash based routing.

            $locationProvider
                .html5Mode(true);

Reference: https://docs.angularjs.org/guide/$location#!

anwalkers commented May 27, 2016

I tried the following code in my Startup.cs to do middleware URL rewrite. It works fine for the base URL, but does not support deep links into an AngularJS 1.x application with HTML5 routing enabled. It does work with HTML5 routing disabled.

Works:
Base URL: http://localhost:5000
API: http://localhost:5000/api/someApi
Library or resource: http://localhost:5000/lib/library.js
HTML5 Routing Disabled: http://localhost:5000/#/angularRoute NOTE: Deep linking works here.

Does not work:
HTML5 Routing Enabled: http://localhost:5000/angularRoute NOTE: This does work if you have loaded the application from the base URL and navigated to the route, but does not work if you have pasted the deep link with the angular route, http://localhost:5000/angularRoute, into a new browser window.

From Startup.cs:

            app.UseMvc();

            // this serves "index.html" from the wwwroot folder when 
            // a route not containing a file extension is not handled by MVC.
            app.MapWhen(context =>
            {
                var path = context.Request.Path.Value.ToLower();
                return path.Contains(".*");
            },
                branch =>
                {
                    branch.Use((context, next) =>
                    {
                        context.Request.Path = new PathString("/index.html");
                        return next();
                    });

                    branch.UseStaticFiles();
                });

Just for clarity, here is a snippet for enabling HTML5 routing in angular 1.x application. It removes the # hash based routing.

            $locationProvider
                .html5Mode(true);

Reference: https://docs.angularjs.org/guide/$location#!

@muratg

This comment has been minimized.

Show comment
Hide comment
@muratg

muratg May 27, 2016

Member

@Tratcher thoughts on why this may have regressed?

cc @pan-wang

Member

muratg commented May 27, 2016

@Tratcher thoughts on why this may have regressed?

cc @pan-wang

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers May 29, 2016

I have published a simple sample app to this repository.

DELETED THIS REPO: https://github.com/anwalkers/AngularUrlRewriteAspNetCore1

This site is a vanilla ASP.Net Core 1 RC2 project using one MVC route to an index.cshtml as the root page for the site. It does not have the mapWhen function or static html in the wwwroot directory. It is checked in a broken state. You can switch it back to non-HTML5 mode by editing the site.js and a bit of markup.

It also does not have mapWhen in the Startup.cs, wasn't sure how to mix the MVC routing and the mapWhen... It does have the rewrite rules in the web.config.

anwalkers commented May 29, 2016

I have published a simple sample app to this repository.

DELETED THIS REPO: https://github.com/anwalkers/AngularUrlRewriteAspNetCore1

This site is a vanilla ASP.Net Core 1 RC2 project using one MVC route to an index.cshtml as the root page for the site. It does not have the mapWhen function or static html in the wwwroot directory. It is checked in a broken state. You can switch it back to non-HTML5 mode by editing the site.js and a bit of markup.

It also does not have mapWhen in the Startup.cs, wasn't sure how to mix the MVC routing and the mapWhen... It does have the rewrite rules in the web.config.

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers Jun 1, 2016

@muratg @Tratcher @pan-wang @ciel Any progress or discussion on this issue?

anwalkers commented Jun 1, 2016

@muratg @Tratcher @pan-wang @ciel Any progress or discussion on this issue?

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 3, 2016

Member

I was able to repro this using just the UrlRewrite samples here:
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
(against ANCM rather than Asp.Net 4).

I see two issues:

  • Kestrel receives the request, but the url has not been modified.
  • Kestrel's response is not forwarded to the client, the client only receives an empty 200 response (Content-Length: 0)

Assigning to @pan-wang to debug.

Member

Tratcher commented Jun 3, 2016

I was able to repro this using just the UrlRewrite samples here:
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
(against ANCM rather than Asp.Net 4).

I see two issues:

  • Kestrel receives the request, but the url has not been modified.
  • Kestrel's response is not forwarded to the client, the client only receives an empty 200 response (Content-Length: 0)

Assigning to @pan-wang to debug.

@WhittenMike807

This comment has been minimized.

Show comment
Hide comment
@WhittenMike807

WhittenMike807 Jun 6, 2016

Has anyone found a work around?

WhittenMike807 commented Jun 6, 2016

Has anyone found a work around?

@ciel

This comment has been minimized.

Show comment
Hide comment
@ciel

ciel Jun 6, 2016

Unfortunately I haven't
On Jun 6, 2016 6:09 PM, "Michael Whittenburg" notifications@github.com
wrote:

Has anyone found a work around?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#192 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAavtJ85Mf7Z36px_PWpZ0USzHGFCazyks5qJKiRgaJpZM4ImD44
.

ciel commented Jun 6, 2016

Unfortunately I haven't
On Jun 6, 2016 6:09 PM, "Michael Whittenburg" notifications@github.com
wrote:

Has anyone found a work around?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#192 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAavtJ85Mf7Z36px_PWpZ0USzHGFCazyks5qJKiRgaJpZM4ImD44
.

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 6, 2016

Member

I did find one where you can change type="Rewrite" to type="Redirect", but I doubt that's relevant to you here.

Member

Tratcher commented Jun 6, 2016

I did find one where you can change type="Rewrite" to type="Redirect", but I doubt that's relevant to you here.

@pan-wang

This comment has been minimized.

Show comment
Hide comment
@pan-wang

pan-wang Jun 7, 2016

Contributor

Looking at it now

Contributor

pan-wang commented Jun 7, 2016

Looking at it now

@anwalkers

This comment has been minimized.

Show comment
Hide comment
@anwalkers

anwalkers Jun 8, 2016

FYI... Found this project with some middleware to solve the url rewrite problem. Something like this would make a nice addition to ASP.Net Core 1.

https://github.com/BrainCrumbz/AWATTS/tree/master/src/WebPackAngular2TypeScript/Routing

anwalkers commented Jun 8, 2016

FYI... Found this project with some middleware to solve the url rewrite problem. Something like this would make a nice addition to ASP.Net Core 1.

https://github.com/BrainCrumbz/AWATTS/tree/master/src/WebPackAngular2TypeScript/Routing

@pan-wang

This comment has been minimized.

Show comment
Hide comment
@pan-wang

pan-wang Jun 8, 2016

Contributor

this is a bug in aspnetcore module. The fix will be included for next release.

Contributor

pan-wang commented Jun 8, 2016

this is a bug in aspnetcore module. The fix will be included for next release.

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 8, 2016

Member

@pan-wang can you provide a brief explanation please?

Member

Tratcher commented Jun 8, 2016

@pan-wang can you provide a brief explanation please?

@Jargon64

This comment has been minimized.

Show comment
Hide comment
@Jargon64

Jargon64 Jun 9, 2016

@anwalkers I'm trying to see if I can get that middleware implemented into my project as a workaround but appears to be for RC1. Did you try it with an RC2 project?

@pan-wang Don't suppose you know when this release is expected to drop?

Jargon64 commented Jun 9, 2016

@anwalkers I'm trying to see if I can get that middleware implemented into my project as a workaround but appears to be for RC1. Did you try it with an RC2 project?

@pan-wang Don't suppose you know when this release is expected to drop?

@WhittenMike807

This comment has been minimized.

Show comment
Hide comment
@WhittenMike807

WhittenMike807 Jun 9, 2016

I was able to use this as a quick workaround.

routes.MapRoute("spa-routes", "{*anything}", new { controller = "Home", action = "Index" });

WhittenMike807 commented Jun 9, 2016

I was able to use this as a quick workaround.

routes.MapRoute("spa-routes", "{*anything}", new { controller = "Home", action = "Index" });

@Jargon64

This comment has been minimized.

Show comment
Hide comment
@Jargon64

Jargon64 Jun 9, 2016

@WhittenMike807 I think this is working for me (have run into the next hurdle while upgrading to RC2).

Are there any known pitfalls of taking this approach?

Jargon64 commented Jun 9, 2016

@WhittenMike807 I think this is working for me (have run into the next hurdle while upgrading to RC2).

Are there any known pitfalls of taking this approach?

@WhittenMike807

This comment has been minimized.

Show comment
Hide comment
@WhittenMike807

WhittenMike807 Jun 9, 2016

I haven't encountered any issue so far. Seems like a "ok" fix for now

WhittenMike807 commented Jun 9, 2016

I haven't encountered any issue so far. Seems like a "ok" fix for now

@Tratcher Tratcher added 3 - Done and removed 1 - Ready labels Jun 10, 2016

@JohnGalt1717

This comment has been minimized.

Show comment
Hide comment
@JohnGalt1717

JohnGalt1717 Jun 13, 2016

FYI, this also blows up and prevents debugging from starting. (works fine in production)

<rewrite>
  <rules>
    <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
      <match url="^(.*)$"/>
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />  
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
    </rule>
  </rules>
</rewrite>

JohnGalt1717 commented Jun 13, 2016

FYI, this also blows up and prevents debugging from starting. (works fine in production)

<rewrite>
  <rules>
    <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
      <match url="^(.*)$"/>
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />  
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
    </rule>
  </rules>
</rewrite>

@Tratcher Tratcher closed this Jun 14, 2016

@WhittenMike807

This comment has been minimized.

Show comment
Hide comment
@WhittenMike807

WhittenMike807 Jun 14, 2016

@Tratcher Why is this closed? Has it been updated/fixed?

WhittenMike807 commented Jun 14, 2016

@Tratcher Why is this closed? Has it been updated/fixed?

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 14, 2016

Member

Yes, this has been fixed for the upcoming release.

Member

Tratcher commented Jun 14, 2016

Yes, this has been fixed for the upcoming release.

@WhittenMike807

This comment has been minimized.

Show comment
Hide comment
@WhittenMike807

WhittenMike807 Jun 14, 2016

@Tratcher Just so I can plan. You have a rough idea on when the next release will be by chance?

WhittenMike807 commented Jun 14, 2016

@Tratcher Just so I can plan. You have a rough idea on when the next release will be by chance?

@Tratcher

This comment has been minimized.

Show comment
Hide comment
Member

Tratcher commented Jun 14, 2016

@Cowlephant

This comment has been minimized.

Show comment
Hide comment
@Cowlephant

Cowlephant Jun 30, 2016

@Tratcher My URL rewriting is still broken with the RTM release. Wasn't this intended to be fixed?

Cowlephant commented Jun 30, 2016

@Tratcher My URL rewriting is still broken with the RTM release. Wasn't this intended to be fixed?

@Tratcher Tratcher reopened this Jun 30, 2016

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 30, 2016

Member

@twilliamsgsnetx yes this was fixed in the 1.0 version of AspNetCoreModule. Have you've installed the new tooling?

Member

Tratcher commented Jun 30, 2016

@twilliamsgsnetx yes this was fixed in the 1.0 version of AspNetCoreModule. Have you've installed the new tooling?

@Cowlephant

This comment has been minimized.

Show comment
Hide comment
@Cowlephant

Cowlephant Jun 30, 2016

@Tratcher I have uninstalled all my previous .NET Core stuff and installed all the new versions, including visual studio tooling.

Could IIS Express be utilizing an older version still somehow? How do I validate my version?

I haven't changed anything in my URL rewriting logic from RC1 either, I don't know if this fix requires any slight modifications.

Cowlephant commented Jun 30, 2016

@Tratcher I have uninstalled all my previous .NET Core stuff and installed all the new versions, including visual studio tooling.

Could IIS Express be utilizing an older version still somehow? How do I validate my version?

I haven't changed anything in my URL rewriting logic from RC1 either, I don't know if this fix requires any slight modifications.

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 30, 2016

Member

Look in (MySolution).vs\config\applicationhost.config and find <add name="AspNetCoreModule" image="%IIS_BIN%\aspnetcore.dll" />. If it says %IIS_BIN%\aspnetcore.dll you should be fine. This maps to C:\Program Files (x86)\IIS Express\aspnetcore.dll who's file version should be 7.1.1967.

Member

Tratcher commented Jun 30, 2016

Look in (MySolution).vs\config\applicationhost.config and find <add name="AspNetCoreModule" image="%IIS_BIN%\aspnetcore.dll" />. If it says %IIS_BIN%\aspnetcore.dll you should be fine. This maps to C:\Program Files (x86)\IIS Express\aspnetcore.dll who's file version should be 7.1.1967.

@Cowlephant

This comment has been minimized.

Show comment
Hide comment
@Cowlephant

Cowlephant Jun 30, 2016

Yes. Mine is set that way, and my file is the version you specified.

For clarification, my project's web.config is as follows

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="true" stdoutLogEnabled="false" />
  </system.webServer>
</configuration>

And my wwwroot config that has the url rewriting logic is as follows:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <!--Redirect selected traffic to index -->
        <rule name="Index Rule" 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" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/account/" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

This was all working handily in RC1 with Angular 2.

Cowlephant commented Jun 30, 2016

Yes. Mine is set that way, and my file is the version you specified.

For clarification, my project's web.config is as follows

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="true" stdoutLogEnabled="false" />
  </system.webServer>
</configuration>

And my wwwroot config that has the url rewriting logic is as follows:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <!--Redirect selected traffic to index -->
        <rule name="Index Rule" 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" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/account/" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

This was all working handily in RC1 with Angular 2.

@Tratcher Tratcher removed the 3 - Done label Jun 30, 2016

@muratg muratg removed this from the 1.0.0 milestone Jun 30, 2016

@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jun 30, 2016

Member

@ZestyBread can you try this?

Member

Tratcher commented Jun 30, 2016

@ZestyBread can you try this?

@jkotalik

This comment has been minimized.

Show comment
Hide comment
@jkotalik

jkotalik Jun 30, 2016

Contributor

The web.config file doesn't exist in wwwroot anymore. Try combining the two together like:

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="true" stdoutLogEnabled="false" />
    <rewrite>
      <rules>
        <!--Redirect selected traffic to index -->
        <rule name="Index Rule" 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" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/account/" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
Contributor

jkotalik commented Jun 30, 2016

The web.config file doesn't exist in wwwroot anymore. Try combining the two together like:

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="true" stdoutLogEnabled="false" />
    <rewrite>
      <rules>
        <!--Redirect selected traffic to index -->
        <rule name="Index Rule" 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" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/account/" negate="true" />
          </conditions>
          <action type="Rewrite" url="/index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
@Cowlephant

This comment has been minimized.

Show comment
Hide comment
@Cowlephant

Cowlephant Jul 1, 2016

@ZestyBread Consolidating to my web.config in the main project as you suggested, my entire app breaks. The client files aren't served properly and angular simply doesn't load.

The rewrite section is specifically what seems to be causing it. I comment that out and everything is fine, except the inability to refresh the site on an angular router URL properly.

I hope I'm not the only one experiencing this issue.

Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/app/content/css/normalize.css". localhost/:8
Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/app/content/css/main.css". localhost/:10
Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/lib/css/vendors.css". shim.min.js:1
Uncaught SyntaxError: Unexpected token < zone.js:1
Uncaught SyntaxError: Unexpected token < Reflect.js:1
Uncaught SyntaxError: Unexpected token < system.src.js:1
Uncaught SyntaxError: Unexpected token < systemjs.config.js:1
Uncaught SyntaxError: Unexpected token < vendors.js:1
Uncaught SyntaxError: Unexpected token < (index):23
Uncaught ReferenceError: System is not defined

Cowlephant commented Jul 1, 2016

@ZestyBread Consolidating to my web.config in the main project as you suggested, my entire app breaks. The client files aren't served properly and angular simply doesn't load.

The rewrite section is specifically what seems to be causing it. I comment that out and everything is fine, except the inability to refresh the site on an angular router URL properly.

I hope I'm not the only one experiencing this issue.

Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/app/content/css/normalize.css". localhost/:8
Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/app/content/css/main.css". localhost/:10
Resource interpreted as Stylesheet but transferred with MIME type text/html:"http://localhost:1412/lib/css/vendors.css". shim.min.js:1
Uncaught SyntaxError: Unexpected token < zone.js:1
Uncaught SyntaxError: Unexpected token < Reflect.js:1
Uncaught SyntaxError: Unexpected token < system.src.js:1
Uncaught SyntaxError: Unexpected token < systemjs.config.js:1
Uncaught SyntaxError: Unexpected token < vendors.js:1
Uncaught SyntaxError: Unexpected token < (index):23
Uncaught ReferenceError: System is not defined
@Tratcher

This comment has been minimized.

Show comment
Hide comment
@Tratcher

Tratcher Jul 1, 2016

Member

Ah, I know what's wrong here. We moved web.config and the app base dir, so rules with file constraints like matchType="IsFile" are looking in the wrong directory.

Workaround: for IIS you can move the web.config back to the wwwroot dir. #164

Real solution: @ZestyBread is writing a url-rewrite middleware so we can move this directly into Asp.Net.

Member

Tratcher commented Jul 1, 2016

Ah, I know what's wrong here. We moved web.config and the app base dir, so rules with file constraints like matchType="IsFile" are looking in the wrong directory.

Workaround: for IIS you can move the web.config back to the wwwroot dir. #164

Real solution: @ZestyBread is writing a url-rewrite middleware so we can move this directly into Asp.Net.

@muratg

This comment has been minimized.

Show comment
Hide comment
@muratg

muratg Jul 5, 2016

Member

Closing this one. aspnet/BasicMiddleware#43 is tracking the middleware work.

Member

muratg commented Jul 5, 2016

Closing this one. aspnet/BasicMiddleware#43 is tracking the middleware work.

@muratg muratg closed this Jul 5, 2016

jkotalik pushed a commit that referenced this issue Dec 8, 2017

fix the AV in recycle process, issue #192. (#201)
* fix the AV in recycle process. this is due to we call Recycle again when the background thread exists

* more fixes

* reset hosting mode when all applications got removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment