Routing does not work on IIS deployment
Hi Mark,
First of all, thanks for this great piece of work.
Issue: After deploying under IIS as an application(Using MSDeploy) running on an app pool(No managed code) under "Default Website", routing is broken and gives 404. Interestingly I have deployed the "https://github.com/aspnet/JavaScriptServices" as is similarly and routing works fine. Is there anything you are doing with respect to routing from JavascriptServices(Angular)
@codehippie1 what does your Startup.cs routing section look like?
I deployed an exact copy of this repository. Did not change any code. My startup.cs is same as https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/Startup.cs
Is ASPNETCORE_ENVIRONMENT=Development set ? Hmm I'm not sure what would be causing IIS to do that. We have a few different setups here to handle /api routes, swagger, etc, but that shouldn't really affect routing for IIS like that.
I'm wondering if the ClientApp folder or something wasn't moved over when you published it to IIS. It might be something missing from the csproj. Is this with a very recent copy of the repo? @codehippie1
- Is ASPNETCORE_ENVIRONMENT=Development set? - Yes
- Is this with a very recent copy of the repo? - Yes, It is the same repo as of today. I just downloaded and published the latest code from https://github.com/MarkPieszak/aspnetcore-angular2-universal now.
Steps to reproduce.
- Download repo https://github.com/MarkPieszak/aspnetcore-angular2-universal
- Open in VS 2017
- Compile and publish to a web deploy package(Release configuration)
- Add an application in IIS manager(IIS 7.5 or above) under default website running on an app pool with no managed code.
- Deploy the msdeploy package(zip)
- Browse the website locally or from a remote machine, click on counter menu, then hit browser refresh button. Page results in 404 with error stating StaticFileHandler.
@MarkPieszak Did I provide adequate info? Have you got a chance to reproduce the issue?
Hi, i had some issues with routing when deployed on IIS because i needed routing to call sub-folder. To resolve it, i have simply used ui-router that make à perfect job without using url redirect or complicated configuration. Give a try to ui-router, i hope it will solve your issue.
If you are still using the old version, you have to deploy from a very specific location on IIS. My .csproj is located in "C:\development\costbooks" so, go from there for reference as to what file to deploy.

After testing, yes, the folder should look similar to the one I have in the picture, the "dotnet publish" command compiles the app into that folder, I believe.