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

 

相关文章:

  • 2022-01-31
  • 2022-01-13
  • 2022-12-23
  • 2021-08-08
  • 2021-09-15
  • 2021-04-17
  • 2021-10-09
  • 2022-01-17
猜你喜欢
  • 2021-06-11
  • 2022-01-06
  • 2021-05-30
  • 2022-02-09
  • 2021-09-24
  • 2022-02-15
  • 2021-08-24
相关资源
相似解决方案