Learning ASP. NET MVC5 framework secrets notes-ASP. NET routing (5), mvc5-asp.net

Source: Internet
Author: User

Learning ASP. NET MVC5 framework secrets notes-ASP. NET routing (5), mvc5-asp.net
3 VirtualPathDath

After introducing the returned type of the GetRouteData method, we will introduce the returned type of the RouteBase GetVirtualPath method VirtualPathData. When the RouteBase GetVirtualPath method is executed, if the variables defined in the routing template match the specified Variable list, it replaces the placeholder corresponding to the routing template with the value of the specified route variable and generates a virtual path. The generated virtual path and Route object are eventually encapsulated into a VirtualPathData object as the return value. They correspond to the VirtualPath and Route attributes of the returned VirtualPathData object. The DataTokens attribute of VirtualPathData and RouteData attributes of the same name are derived from the set of custom variables attached to the Route object.

public class VirtualPathData{public VirtualPathData(RouteBase route, string virtualPath);public RouteValueDictionary DataTokens { get; }public RouteBase Route { set; get; }public string VirtualPath { set; get; }}

The GetVirtualPath method of RouteBase has a parameter of the RequestContext type. A RequestContext object indicates the context of a request. It is not difficult to see from the following code snippets that it is actually an encapsulation of HTTP context and RouteData.

public class RequestContext{public RequestContext(HttpContextBase httpContext,RouteData routeData);public RequestContext();public virtual HttpContextBase HttpContext { set; get; }public virtual RouteData RouteData { set; get; }}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.