【发布时间】:2017-06-29 17:20:27
【问题描述】:
我想通过能够传递变量将用户重定向到此链接
public ActionResult GoogleMapAddress(string address, string Area, string city, string zipCode)
{
return Redirect(string.Format(" https://www.google.co.za/maps/search/{0}/ ", address + Area + city + zipCode));
}
观点
@Html.ActionLink("Address", "GoogleMapAddress", "Orders", new { address="test", Area="test", city="test", zipCode="test" },new {target="_blank" })
我将Url链接添加到localhost链接的当前方法。这给出了错误- “从客户端 (:) 检测到潜在危险的 Request.Path 值。” 一旦我删除添加的 localhost 链接,url 链接(google)就可以工作
【问题讨论】:
-
由于是手动生成url,所以需要使用
Url.Encode(address + Area + city + zipCode) -
连接地址后需要使用
Response.Redirect(url) -
当客户端已经拥有发出 js 重定向所需的所有信息时,为什么还要进行服务器调用?
标签: c# asp.net-mvc url