简体   繁体   English

剃刀将字符串隐藏为URL

[英]Razor concatinate a string into a URL

I am trying to concatinate some data in Razor to make a URL with a query string, along the lines of :- 我正在尝试在Razor中添加一些数据,以使带有查询字符串的URL沿着:-

<a href= "www.Mysite.com" + "?ID="+ @Html.Raw(m.intItemIdentifier) >  @Html.Raw(m.strItemHeadline) </a><br />

and yes I know RAW will bring back unencoded data, and I cannot alter the database. 是的,我知道RAW将带回未编码的数据,并且我无法更改数据库。

I guess the code you show is not rendering the URL you want. 您显示的代码没有呈现您想要的URL。

Use either 使用任一

<a href="http://www.example.com?ID=@(Html.Raw(m.intItemIdentifier))"> 

Or 要么

<a href="@Html.Raw("http://www.example.com?ID=" + m.intItemIdentifier)"> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM