zoukankan      html  css  js  c++  java
  • 使用指定的 URL 模式和处理程序类初始化 Route 类的新实例(仅供参考,高手绕过)

    创建及使用Routing类,注意,该类只能在全局处理程序的 Application_Start(object sender, EventArgs e) 方法中使用才是有意义的:

    代码
    void Application_Start(object sender, EventArgs e) 
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.Add(
    new Route
        (
             
    "Category/{action}/{categoryName}"
             , 
    new CategoryRouteHandler()
        ));
    }

    需要注意的是,Route 的构造函数 (String, IRouteHandler)中,IRouteHandler是一个接口,不能直接实例化,但可以创建新的类来实现它的 GetHttpHandler 方法

     public IHttpHandler GetHttpHandler(RequestContext requestContext)
            {
                
    return new MyPage(requestContext);
            }

    RequestContext是客户请求的上下文,直接由URL来提供。(基于.Net 3.5 SP1)

  • 相关阅读:
    S03E01 蓝牙操作
    GET与POST方法
    Http请求头与响应头
    HttpClient初步
    Http
    深度为H的满k叉树
    html5-css选择器
    html5-css的使用强制优先级
    html5-样式表的使用-初步
    html5-css的引入
  • 原文地址:https://www.cnblogs.com/MicroGoogle/p/1628657.html
Copyright © 2011-2022 走看看