在WebMatrix中使用网页,我想将用户发送到谷歌地图,但我无法使用外部网址而不会出现以下错误:
"从客户端(:)发现了一个潜在危险的Request.Path值。"
我设置了一个值表格,地址栏会将用户带到谷歌地图。
<tbody>
@foreach(var item in rowItems)
{
var addr = item.AddressDisplay;
var url = "@http://maps.google.com/?q";
//var addr = rawaddr.Replace(" ", "+");
url = HttpUtility.UrlEncode(url + addr);
<tr>
<td class="tableCallAlighLeft">@item.EventDate.ToString("MM/dd/yyyy")</td>
<td class="tableCallAlighLeft">@item.EventType</td>
<td class="tableCellAlignLeft">@item.TimeStart.ToString("hh:mm tt")</td>
<td class="tableCellAlignLeft">@item.TimeEnd.ToString("hh:mm tt")</td>
<td class="tableCellAlignLeft">@item.VenueName</td>
<td class="tableCellAlignLeft"><a href="@url">@item.AddressDisplay</a></td>
<td class="tableCellAlignLeft">@item.CostMin.ToString("C")</td>
<td class="tableCellAlignLeft">@item.CostMax.ToString("C")</td>
<td class="tableCellAlignLeft">@item.Family</td>
<td class="tableCellAlignLeft">@item.MinAge</td>
<td class="tableCellAlignLeft">@item.Adult</td>
</tr>
}
</tbody>
如何允许item.AddressDisplay转到Google地图?
谢谢!
答案 0 :(得分:0)
我最终这样做了:
<a href='@string.Format("http://maps.google.com?q={0}", addr)'>@item.AddressDisplay</a>