zoukankan      html  css  js  c++  java
  • mvc 路由

    public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    name: "ad",
                    url: "{controller}/{action}/sid{sid}/adid{adid}/{id}",
                    defaults: new { controller = "Main", action = "Index", sid = UrlParameter.Optional,adid=UrlParameter.Optional,id = UrlParameter.Optional },
                    constraints: new { sid = @"d+" }
                );
    
                //routes.MapRoute(
                //    name: "share",
                //    url: "{controller}/{action}/sid{sid}/{id}",
                //    defaults: new { controller = "Main", action = "Index", sid = UrlParameter.Optional, id = UrlParameter.Optional },
                //    constraints: new { sid = @"d+" }
                //);
    
                routes.MapRoute(
                    name: "share",
                    url: "{sid}/{controller}/{action}/{id}",
                    defaults: new { controller = "Main", action = "Index1", sid = UrlParameter.Optional, id = UrlParameter.Optional },
                    constraints: new { sid = @"d+" }
                );
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Main", action = "Index", id = UrlParameter.Optional }
                );
            }
            public ActionResult Index1(int sid,Guid? id)
            {
                Response.Write(RouteData.GetRequiredString("sid").ToString());
                return Content(string.Format("<br/>sid={0}<br />id={1}<br />", sid, id));
            }
  • 相关阅读:
    JavaScript中弧度和角度的转换
    HTML <meta> Attribute
    rel 属性<small>H5保留属性</small>
    React学习笔记
    React学习笔记
    jQuery插件制作
    jQuery ajax
    js数据存贮之数组与json
    列表与表格的一些学习
    18-10-16学习内容总结
  • 原文地址:https://www.cnblogs.com/shiningrise/p/5530270.html
Copyright © 2011-2022 走看看