zoukankan      html  css  js  c++  java
  • ASP.NET 短路由配置

    1. 首先在项目新建文件叫App_Code或者App_Start

        在文件中新建WebFromRouteHandler.cs 文件。

        WebFromRouteHandler中的代码如下,

    public class WebFromRouteHandler : IRouteHandler
    {
        public WebFromRouteHandler(string virtualPath)
        {
            this._VirtualPath = virtualPath;
        }
     
        private string _VirtualPath;
     
        public string VirtualPath
        {
            get { return _VirtualPath; }
            set { _VirtualPath = value; }
        }
     
     
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(Page)) as IHttpHandler;
            return page;
        }
     
     
    }


    2. Global.asax 中的代码如下:

    public class Global : HttpApplication
       {
           void Application_Start(object sender, EventArgs e)
           {
               // 在应用程序启动时运行的代码
               AuthConfig.RegisterOpenAuth();
             
               RegisterRoutes(RouteTable.Routes);
           }
     
           void Application_End(object sender, EventArgs e)
           {
               //  在应用程序关闭时运行的代码
     
           }
     
           void Application_Error(object sender, EventArgs e)
           {
               // 在出现未处理的错误时运行的代码
     
           }
     
           public static void RegisterRoutes(RouteCollection routes)
           {
               routes.Add("Named", new Route("Named", new WebFromRouteHandler("/About.aspx")));
           }
      
       }
     3. 页面调用

       <form id="form" runat="server">
           <asp:LinkButton ID="LinkButton1" PostBackUrl="/Named" runat="server">LinkButton</asp:LinkButton>
       </form>





  • 相关阅读:
    spring mvc随便接收list<objeect>参数
    python django model类型摘要
    【Unity3D自我记录】解决NGUI通过问题触发事件点
    sqlcipher移植
    外键约束列并没有导致大量建筑指数library cache pin/library cache lock
    34一个美丽的生活窍门
    html表格合并(行,一排)
    01标题背包水章 HDU2955——Robberies
    苹果Swift编程语言新手教程【中国版】
    神经网络和BP算法推导
  • 原文地址:https://www.cnblogs.com/youmingkuang/p/4649373.html
Copyright © 2011-2022 走看看