2013-06-27 68 views
0

我們在我們的網站上收到多個HttpRequestValidationExceptions。我們恰當地捕捉到這些,但是想要更詳細地記錄它們。被抓的消息顯示HttpRequestValidationException - 如何獲得完整的值輸入?

"A potentially dangerous Request.Form value was detected from the client (ctl00$txtSearch=\"<a href=\"www.google.com...\")."} 

我們想知道什麼是在文本框中輸入的全文,並不會做任何事,除了記錄它。我知道我輸入了

<a href="www.google.com">www.google.com</a> 

但是正如你所看到的,它沒有在異常的消息部分中顯示所有這些。 InnerException爲null,所以這沒有幫助。

這是我們使用的代碼:

void Application_Error(object sender, EventArgs e) 
{ 
    // Get the last exception that has occurred 
    if (Server.GetLastError() != null) 
    { 
     var ex = Server.GetLastError().GetBaseException(); 
     //...log it here 
    } 
} 

我們怎樣才能得到充分的文本輸入到文本框?關閉頁面驗證不是一個選項。先謝謝你!

回答

0

​​

使用的Request.Form [ 「鍵名」]捕最後一個異常後。

var val = Request.Form [「txtInput1」];

您還可以使用

​​

上面我有tbSource爲文本框和捕捉上的Application_Error

價值
相關問題