• MVC重定向-自定义路由篇


        public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                     name: "Rewrite",
                     url: "product/c{Industry}/{id}",
                     defaults: new { controller = "Rewrite", action = "NIndex", id = UrlParameter.Optional },constraints:new {id=@"d+", Industry=@"d+"}
    
                 );
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
                );
            }
        }
     public class RewriteController : Controller
        {
            // GET: Rewrite
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult NIndex(int Industry, int id)
            {
                ViewBag.Result = string.Format("该产品的行业是{0},编号是{1}",Industry,id);
                return View("Index");
    
            }
        }
  • 相关阅读:
    功能规格说明书
    绝望的作业
    php闭包
    php isset emtpy
    PHP超级全局变量、魔术变量和魔术函数
    死锁的一个例子
    php session cookie
    http状态码301、302
    php浮点数
    学过的设计模式
  • 原文地址:https://www.cnblogs.com/l1pe1/p/5996839.html
Copyright © 2020-2023  润新知