摘要:解決ValidateRequest的失效問題
在網頁裡,若頁面要取消針對XSS攻擊的防禦,必須在頁面上加上ValidateRequest="false",然而在.Net 4.0裡,ValidateRequest是失效的,必須
將驗證方式設定成2.0模式,如下,在web.config裡加入:
	
	    <system.web>
	      <httpRuntime requestValidationMode="2.0" />
	    </system.web>
然而,並不是每一個網頁都要開啟其對XSS攻擊的防禦,可能只是一個頁面有這個需求,因此在config檔裡再加上<location path="xxx">
	<location path="index.aspx">
	    <system.web>
	      <httpRuntime requestValidationMode="2.0" />
	    </system.web>
	</location>
並在index.aspx網頁上加上ValidateRequest="false"即可解決失效的問題。