I want to change the address of a function (via RegisterRoutes). I defined two routes.MapRoute but not working any. I checked many examples and matched my code with them, but the problem still remains. The real address is: http://localhost:3127/account/register/3
I want my address to be changed to the following address: http://localhost:3127/Reg
Should [Route("Reg")] be used at the top of the function for this? Is a redirect required for this or not? Do I need web.config settings to do this?
my action is:
[AllowAnonymous]
[Route("Reg")]
public virtual ActionResult Register()
{
return View();
}
my configuration in Register Routes:
routes.MapRoute(
name: "Register",
url: "Reg",
defaults: new { controller = "Account", action = "Register" },
namespaces: new[] { "WebSite.Controllers" }
);
routes.MapRoute(
name: "Account",
url: "Account/Reg",
defaults: new { controller = "Account", action = "Register" },
namespaces: new[] { "WebSite.Controllers" });