zoukankan      html  css  js  c++  java
  • MVC Rounting System 学习心得(二)

    1.Generating Outgoing URLs in Views  
    Rules:

      routes.MapRoute("MyRoute", "{controller}/{action}/{id}", 
                    new { controller = "Home", action = "Index",  
                        id = UrlParameter.Optional }); 
            } 

    View:

    1.  <div> 
              @Html.ActionLink("This is an outgoing URL", "CustomVariable") 
          </div> 

      Html:

      <a href="/Home/CustomVariable">This is an outgoing URL</a> 
      
     routes.MapRoute("NewRoute", "App/Do{action}", 
            new { controller = "Home" }); 

    Html:

    <a href="/App/DoCustomVariable">This is an outgoing URL</a>
    

    2.Generating Outgoing URLs in Views  

    It's not a link, just a literal string.

     @Url.Action("Index", "Home", new { id = "MyId" }) 
  • 相关阅读:
    登录认证
    json
    关于优化
    网站资源
    设计模式
    Python
    查兰IP
    Linux命令
    centos7.0KVM虚拟化
    Shell数组
  • 原文地址:https://www.cnblogs.com/shineqiujuan/p/3100813.html
Copyright © 2011-2022 走看看