zoukankan      html  css  js  c++  java
  • ASP.NET MVC5 实现网址伪静态

    一、路由规则:
    routes.MapRoute(
                    name: "Default1",
                    url: "more_{root}_{plate}.html",
                    defaults: new { controller = "about", action = "Index", root = UrlParameter.Optional, plate = UrlParameter.Optional }
                );
    
    二、定义URL:
    <a href="@Url.Action("index", "about", new { root = 1, plate = 2 })">123456</a>
    
    三、在VIew获取参数:
    <p>root: @(Url.RequestContext.RouteData.Values["root"])</p>
    <p>plate: @(Url.RequestContext.RouteData.Values["plate"]) </p>

    还需要在webconfig配置:

    ASP.NET MVC4 项目 伪静态 - IsNullOrEmpty - YIYI的博客

    public IEnumerator <string> GetEnumerator()// 注意:返回什么,泛型就为什么类型
        {
            for (int i = 0; i<arr_Course.Length; i++)
            {
                Course course = arr_Course[i];
                yield return "选修:" + course.Name;
                yield return Environment.NewLine;// 两个 yield return
            }
        }
    public IEnumerator <string> GetEnumerator()// 注意:返回什么,泛型就为什么类型
        {
            for (int i = 0; i<arr_Course.Length; i++)
            {
                Course course = arr_Course[i];
                yield return "选修:" + course.Name;
                yield return Environment.NewLine;// 两个 yield return
            }
        }
    

      

  • 相关阅读:
    知识图谱
    spring mvc踩坑记
    学习计划
    迷茫中看见一道曙光
    面试复习准备
    关于配置httpd2.4.18+php5.6
    notepad++ 等用正则表达式自动添加sql引号(宏)
    JDK1.8的HashMap实现原理和源码解析
    Java垃圾回收机制
    sql server 表分区
  • 原文地址:https://www.cnblogs.com/vjiedao/p/3631923.html
Copyright © 2011-2022 走看看