Look directly at the code and comments.
ASP. NET MVC Router
Public classrouteconfig{ Public Static voidregisterroutes (routecollection routes) {routes. Ignoreroute ("{Resource}.axd/{*pathinfo}"); Routes. Ignoreroute ("Favicon.ico"); Routes. Mapmvcattributeroutes (); //be sure to routes. MapRoute before registration//single-page processingroutes. MapRoute (Name:"Personalprofile", URL:"Personal-profile/{*pathinfo}",//This allows you to connect all under Personal-profile paths to the same controller.DefaultsNew{controller ="Personalprofile", action ="Index", PathInfo ="PathInfo" } ); //The general treatmentroutes. MapRoute (Name:"Default", URL:"{Controller}/{action}/{id}", defaults:New{controller ="Home", action ="Index", id =urlparameter.optional}); }}
ASP. NET Controller
[Routeprefix ("personal-profile")]publicclass personalprofilecontroller:controller{ //[route ("")] public ActionResult Index (string pathInfo) { //PathInfo We can also handle it separately return View ();} }
One thing to note here is that if you use Attributeroute, Routemap will not work.
Cshtml Angular
@{Layout = null;}<!DOCTYPE HTML><HTMLNg-app= "App"Ng-controller= "Ctrl"><Head> <Basehref= "http://localhost:58404/personal-profile/" /> <Metaname= "Viewport"content= "Width=device-width" /> <title>Index</title></Head><Body>Personal Profile<Scriptsrc= "~/js/jquery.js"></Script> <Scriptsrc= "~/js/angular.js"></Script> <Script> varapp=Angular.module ("app", []); App. Config (["$locationProvider", function($locationProvider) {//Note: //because angular will compare the URL of the browser when doing $location and <base> //and it's case-sensitive, so it's easy to error. //you won't have this problem after reset. //the procedure is to take the URL of the browser replace into base href varWholeurl=Location.href; varBaseelem=document.getElementsByTagName ("Base")[0]; varBASEURL=Baseelem.href; varNewbaseurl=wholeurl.substring (0, baseurl.length); Baseelem.href=Newbaseurl; $locationProvider. Html5mode ({enabled:true, Requirebase:true }); }]); App.controller ("Ctrl", ["$location", function($location) {Console.log ("Start"); }]); </Script></Body></HTML>
Notice the conflict between angular and base
Some ways of MVC route and Angular Router single page