【发布时间】:2018-09-18 16:15:34
【问题描述】:
在我的剃须刀页面中。
<p>
<span>Website: </span>
<span>
<a href="@(Url.Encode(Model.PrimaryInfo.WebsiteUrl))" target="_blank">@Model.PrimaryInfo.WebsiteUrl</a>
</span>
</p>
当我检查我看到的元素时。 页面显示为
当我检查元素时,我得到了
<a href="https%3a%2f%2fwww.mywebsite.org%2f" target="_blank">https://www.mywebsite.org/</a>
当我点击链接时,我得到了
[HttpException (0x80004005): 有潜在危险的 Request.Path 从客户端检测到值 (:)。]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9939972
System.Web.PipelineStepManager.ValidateHelper(HttpContext 上下文) +53
【问题讨论】:
-
删除 Url.Encode.
-
在没有 url.encode 的情况下仍然会收到潜在危险的请求
-
这是非常危险的,但您应该能够将 Html.Raw() 值输出。 Be really careful here, Raw() is extraordinarily dangerous。 Dangers 和 google 更多,请了解它的作用。
标签: c# asp.net asp.net-mvc