I am doing an ASP.NET MVC 5 website with AngularJS.
I want to have a web site (SEO) and a web application site (AngularJS).
I want to switch to the SPA via “Go to SPA” link.
I want to switch back to the website via click on the home/house icon on the SPA.
When I do this switching I want to exchange the whole layout.
How would I do this with asp.net mvc?
2
Answers
Just create two main .cshtml files. One cshtml for the regular app, and the second for the angular app with ng-view.
Now about swithcing from one file to another use window.location.href = ‘your-cshtml-file’.
Write your website as you would a standard MVC app. Then write an MVC controller that returns the .cshtml file of your angular app and set
Layout = null;
at the top. With this approach you can access everything through the .NET MVC routing and controllers and your angular app doesn’t have any of your MVC layout in it.