How to set routing to have some controller actions handled by angular

I'm working on a legacy .NET MVC project with an "Account" controller.

It has a number of actions that I don't want to mess with - e.g. Account/Login , Account/ManageProfile.

The route Account/ is not handled (not sure if that is useful info)

My goal is to have AngularJS handle the Register and ForgotPassword actions in one angular app.

Currently, I have set up everything for Register and it works; there's an action in the Account controller:

    [AllowAnonymous]
    public ActionResult Register()
    {
        return View();
    }

In Angular, the route "/" points to the registration page. And the subsequent URL is /Account/Register#/ There is one angular view.

Now to add a ForgotPassword action, I could copy everything I did for Register and end up with /Account/ForgotPassword#/ . This would mean setting up another angular app to handle it - using the angular route "/"

I would prefer instead to have URLs: /Account/#Register and /Account/#ForgotPassword and then use angular's routing service to decide whether to load the Register or Forgot angular views. I'd like to do this without messing up the legacy Account actions, although ultimately I'd like to migrate other actions to come under the ng-app.

I understand Angular's routing.

So my question is how do I set up RouteConfig.cs to handle /Account/#Register and /Account/#ForgotPassword in such a way that angular handles the action part of the routing?


ANSWERS:


The hash part of the URL (# and everything afterwards) is not sent to the server, so, the routing cannot handle it.

You can of course have an Index action that handles anything in Account and this one will initialise the Angular application with "Angular" routing set for handling / (which is actually /Account/#/) and /ForgotPassword (which is /Account/#/ForgotPassword). This is probably the closest you want.

In similar apps I didn't have that much shared so each MVC action was its own Angular app. I shared directives and more stuff in a shared directive that each page Angular app had as a dependency.



 MORE:


 ? Angular routing vs MVC routes
 ? ASP.NET MVC Angular routing
 ? Angular-routing, direct URL navigation
 ? C# mvc angular $rngRoute $http.get mixed up
 ? MVC Renders Razor template on normal page load but not when Angular ngRoute gets it as templateUrl
 ? Why does my AngularJS home page not load when linked from itself
 ? Why does my AngularJS home page not load when linked from itself
 ? Why does my AngularJS home page not load when linked from itself
 ? Generate static SEO pages for AngularJS + Spring MVC website
 ? Route to different View(use @Html.ActionLink and ng-view in View) in Asp.Net MVC with AngularJS, ng-view only work one time, location url strange