I have an Area called Vendor, which is accessed using this url:
mysite.com/Vendor/Home/index
This name, is only for internal use however, so I would like to change it ONLY in the url to 'All'; like so:
mysite.com/All/Home/index
I setup the VendorAreaRegistration file as follows:
public override string AreaName
{
get { return "All"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: AreaName + "_default",
url: AreaName + "/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional };
}
The idea was, that the routing would just look different, but it would actually search for 'Vendor'. This is not the case however. Now it can't find any of my views, because it is looking for the 'index' file in an 'all' folder that doesn't exist.
Is there any way to do this, changing the names of any of the files or views?
An Area is something that controls both the location of the views and the URLs. However, routing only pertains to URLs. So if you want only want the URL to be different and not the file location, you should only change the routing.
public override string AreaName
{
get { return "Vendor"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: AreaName + "_default",
url: "All/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional };
}