Reputation: 1821
I'm going to use Area in my ASP.Net MVC project, but I'm not sure Can I do what I want, or no? because I'm new in MVC.
So I have some Name in my database like this :
Name1
Name2
Name5 and so on
So I want to use area and have a url like this:
www.mysite.com/Name1/Home/Index
User can change Name1 , How can I check in database if Name1 Exist ? I mean where can I check this?
My AreaRegistration likes this:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"MyArea_default",
"{arename}/{controller}/{action}/{id}",
new {action = "Index", id = UrlParameter.Optional }
);
}
Upvotes: 0
Views: 53
Reputation: 2159
In order to achieve the desired functionality you would have to create a custom route constraint. This is explained in depth at http://www.asp.net/mvc/tutorials/controllers-and-routing/creating-a-custom-route-constraint-cs :)
You would perform the check against your existing database records in the Match() method. Please refer to the provided documentation for further explanation :) It's a pretty easy read.
Upvotes: 2