I'm trying to configure a route for the url pattern "http://localhost:1234/#/animal"
Basically I want different actions to be executed for "http://localhost:1234" and "http://localhost:1234/#/animal"
So I added a route like below.
routes.MapRoute(
name: "DefaultHashed",
url: "#/{id}",
defaults: new { controller = "Default", action = "HashedIndex", id = UrlParameter.Optional }
);
But it still uses the Default route shown below and not DefaultHashed route. What am i missing?
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
);
Edit: This is an ASP.NET MVC with Angular SPA. The Index action of default controller is shown below.
public ActionResult Index(int id)
{
if (User?.IsAuthenticated)
{
return View("/dist/Index.cshtml");
}
return RedirectToAction("SignIn", "Authentication");
}
Here I want to redirect to external url if the posted url is "http://localhost:1234". if not I should load the angular page.