Reputation: 21147
I'm attempting to build a single page application using AngularJS on the client side and asp.net with Web API on the backend. I've been utilizing a complex client side build pipeline using Grunt. Long story short, this tool provides me a dist
folder which contains all of my scripts/styles etc and is minified, uglified and all that good stuff.
At this point, I have no need for the server side MVC pipeline when it comes to URL routing and view rendering. I've placed the dist package at siteroot/Content/dist
. Ultimately, my goal is to statically serve the files located there and leave the rest of the application intact. However, I've found no way to be able to do this. I'm forced to navigate to mysite.com/content/dist
in order to actually see my application. I discovered virtual applications and directories and have attempted to remap the application at /
to site\wwwroot\Content\dist
. This has the intended effect in that now navigating to the root of my site serves the HTML files I'm looking for, however it simultaneously seems to break all of my Web API endpoints as it appears that the application is running out of a different path entirely.
Is there a way that I can have the best of both worlds? I want my API endpoints to exist as they do now but simply serve my site statically out of \Content\dist
Upvotes: 0
Views: 1345
Reputation: 4986
You can use the StaticFiles middleware and set your dist folder as the root. I have an example how to set this up in a console application, but all you would need in an existing web app is to have a Startup class to configure in the middleware.
Upvotes: 2