2016-10-04 64 views
3

我需要使用基於vb.net的web服務中的oneignal向客戶端發送消息。這些消息像HTML標籤之間發送:<html><body>message<a href="...">link</a>text,但每當我試圖通過一個信號發送它,我得到這個錯誤:我們如何發送onesignal中的html標籤?

System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (pushMessage=&quot;message&lt;a&gt;link&lt;/a&gt;text&quot;). 
    at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) 
    at System.Web.HttpRequest.ValidateHttpValueCollection(HttpValueCollection collection, RequestValidationSource requestCollection) 
    at System.Web.HttpRequest.get_Form() 
    at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) 
    at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 
    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() 

有人能提出一個解決方案,通過onesignal發送HTML數據?

回答

1

此錯誤似乎發生在您的服務器端,而不是來自OneSignal。

這是微軟對這一錯誤消息指南:https://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(v=vs.110).aspx

在上面的鏈接解釋如何解決此備註部分,引用:

Constraining and validating user input is essential in a Web application to prevent hacker attacks that rely on malicious input strings. Cross-site scripting attacks are one example of such hacks. Other types of malicious or undesired data can be passed in a request through various forms of input. By limiting the kinds of data that is passed at a low level in an application, you can prevent undesirable events, even when programmers who are using your code do not put the proper validation techniques in place.

Request validation detects potentially malicious client input and throws this exception to abort processing of the request. A request abort can indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. It is strongly recommended that your application explicitly check all input regarding request aborts. However, you can disable request validation by setting the validateRequest attribute in the directive to false, as shown in the following example: <%@ Page validateRequest="false" %> To disable request validation for your application, you must modify or create a Web.config file for your application and set the validateRequest attribute of the pages section to false, as shown in the following example:

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

To disable request validation for all applications on your server, you can make this modification to the Machine.config file.

相關問題