這個問題遇到好幾次了,每次忘記都要再去 google 摳比這行,乾脆記在這裡筆記
有時頁面上會遇到如下的錯誤訊息
錯誤訊息 : 具有潛在危險 Request.QueryString 的值已從用戶端 .....
這是因為傳遞的內容中含有 html tag or script 之類的
之前都是把 ValidateRequest="false"
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %>
但現在光設定這個已經沒用了
除了在 Page 指示詞加 ValidateRequest = "false"
也要在 web.config 加上
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
這是因為在 ASP.net 4.0 之中驗證的範圍已經擴大到所有的 http 請求
(以前是只有單一頁面與該頁面的 class)
加上這行才能讓驗證只發生在該頁面
全站熱搜