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 MVC5 实现网址伪静态

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
        }
    }