ASP.NET Request 驗證

ASP.NET內建提供基本的 request 驗證在表單提交或 postback處理時。每個網頁預設是有 Request 驗證,但是在不同版的 .NET Framework 有不同的處理方法。

ASP.NET 1.1 Request 驗證

  • Filter "&#"
  • Filter ‘<’ then alphas or ! or / (tags)
  • Filter "script:"
  • Filter on handlers (onXXX=)
  • Filter “expression(“
  • Ignore elements named "__VIEWSTATE"

ASP.NET 2.0 Request 驗證

  • Filter "&#"
  • Filter ‘<’ then alphas or ! or / (tags)
  • Ignore elements with names prefixed with double underscore (__)

ASP.NET 4.0 Request 驗證

  • 所有Request皆執行驗證,HttpHandler和HttpModules甚至靜態網頁

ValidateRequest 設定

單一網頁設定:

<%@ Page validateRequest="true|false" %>

整個應用程式設定:

<configuration>
<system.web>
<pages validateRequest="true|false" />
</system.web>
</configuration>

.NET 4.0 使用2.0方式驗證

<system.web>
<httpRuntime requestValidationMode="2.0"/>
</system.web>

留言

這個網誌中的熱門文章

IIS 啟用HTTP Strict Transport Security (HSTS)

解決WCF(REST)在https出現檔案找不到錯誤

Azure Web Apps 讀取憑證