URL stand for Uniform Resource Locator
for example www.abc.com/directory/emplyee.htm
URI is an identifier for some resource, but a URL gives you specific information as to obtain that resource.URL doesn’t necessarily mean a physical location of a static file on a web server’s
hard drive somewhere ,it means some unique identifier.
Most of the cases Webserver and then directory and sub directory and file name
But in MVC the method is different
Route definitions start with the URL pattern, which specifies the pattern that the route will match. Along with the route URL, routes can also specify default values and constraints for the various parts of the URL, providing tight control over how and when the route matches incoming request URLs
Application_Start() method contains a call to a method named the
RegisterRoutes method
public static void RegisterRoutes ( RouteCollection routes )
{
routes.MapRoute( “example”, “{first}/{second}/{third}”);
}
Routing: /albums /display/123
Result: first = “albums” second = “display” third = “123”
routes.MapRoute(“simple”, “{first}/{second}/{third}”);
The {action} parameter value is used to indicate which method of the controller to call in order
to handle the current request. Note that this method invocation applies only to controller classes
that inherit from the System.Web.Mvc.Controller base class. Classes that directly implement
IController can implement their own conventions for handling mapping code to handle the
request.
Any route parameters other than {controller} and {action} can be passed as parameters to the
action method, if they exist. For example, assuming the following controller:
public class AlbumsController : Controller
{
public ActionResult Display(int id)
{
return View();
}
}
ROUTE URL PATTERN EXAMPLES OF URLS THAT MATCH
{controller}/{action}/{genre} /albums/list/rock
service/{action}-{format} /service/display-xml
{report}/{year}/{month} /{day} /sales/2008/1/23
routes.MapRoute(“simple”, “{controller}/{action}/{id}”,new {id = UrlParameter.Optional});
Multiple default values can be provided. The following snippet demonstrates providing a default
value for the {action} parameter as well:
routes.MapRoute(“simple”, “{controller}/{action}/{id}”, new {id = UrlParameter.Optional, action=”index”});
using System.Web.Routing;
for example www.abc.com/directory/emplyee.htm
URI is an identifier for some resource, but a URL gives you specific information as to obtain that resource.URL doesn’t necessarily mean a physical location of a static file on a web server’s
hard drive somewhere ,it means some unique identifier.
Most of the cases Webserver and then directory and sub directory and file name
But in MVC the method is different
- MVC matches controller action rather than file system
- MVC also matches outgoing request with controller action rather than file system
Route definitions start with the URL pattern, which specifies the pattern that the route will match. Along with the route URL, routes can also specify default values and constraints for the various parts of the URL, providing tight control over how and when the route matches incoming request URLs
Application_Start() method contains a call to a method named the
RegisterRoutes method
public static void RegisterRoutes ( RouteCollection routes )
{
routes.MapRoute( “example”, “{first}/{second}/{third}”);
}
Routing: /albums /display/123
Result: first = “albums” second = “display” third = “123”
routes.MapRoute(“simple”, “{first}/{second}/{third}”);
The {action} parameter value is used to indicate which method of the controller to call in order
to handle the current request. Note that this method invocation applies only to controller classes
that inherit from the System.Web.Mvc.Controller base class. Classes that directly implement
IController can implement their own conventions for handling mapping code to handle the
request.
Any route parameters other than {controller} and {action} can be passed as parameters to the
action method, if they exist. For example, assuming the following controller:
public class AlbumsController : Controller
{
public ActionResult Display(int id)
{
return View();
}
}
ROUTE URL PATTERN EXAMPLES OF URLS THAT MATCH
{controller}/{action}/{genre} /albums/list/rock
service/{action}-{format} /service/display-xml
{report}/{year}/{month} /{day} /sales/2008/1/23
routes.MapRoute(“simple”, “{controller}/{action}/{id}”,new {id = UrlParameter.Optional});
Multiple default values can be provided. The following snippet demonstrates providing a default
value for the {action} parameter as well:
routes.MapRoute(“simple”, “{controller}/{action}/{id}”, new {id = UrlParameter.Optional, action=”index”});
using System.Web.Routing;