In ASP.net MVC Routing works following way and need to register in Application_Start of Global.asax
Default Route when ASP.net MVC Application created
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Default", action = "Index", id = UrlParameter.Optional });
Default route has placeholder that done most of work.
For example :
if request is made for http://<<yoursite>//Home/Index.
This will call HomeController’s Index method.
if request is made for http://<<yousite>//Home/Index/1
This will call HomeController’s Index method with argument value “1”.
Sample Controller:
public class HomeController : Controller
{
public ActionResult Index(string id)
{
return new ContentResult() { Content = "This is Index" };
}
}
Next Part will going to give you detail about “Slugish Url”.
Think Better To Build Best.
Blog by Jinal Patel.
Microsoft .NET Technology,SharePoint 2007,SharePoint 2010,ASP.net MVC
Sunday, July 18, 2010
ASP.net MVC Routing - Part1
Labels:
ASP.net MVC,
C# 3.0
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment