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));
            }
  • 相关阅读:
    Delphi中 弹出框的用法
    VC++代码上传到VSS上 注意事项
    VC++ 屏蔽掉警告
    IIS LocalDB 登录失败
    SVN版本回滚实战
    Git常用命令图解
    C# 百度API地址坐标互相转换
    Quartz.NET浅谈一 : 简单Job使用(定时发送QQ邮件)
    发布自己的类库包到Nuget
    C# 常用日期取得
  • 原文地址:https://www.cnblogs.com/shiningrise/p/5530270.html
Copyright © 2011-2022 走看看