H.Al H.Al - 5 months ago 35
HTML Question

How can we send html tags in onesignal?

I need to send messages to clients using onesignal from my webservice based on vb.net. Those messages are sent between html tags like :

<html><body>message<a href="...">link</a>text
, but whenever I try to send it through one signal i got this error:

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()

Can someone suggest a solution to send html data through onesignal?


This error appears to be happening on your server side, and not from OneSignal.

Here is Microsoft's guide on this error message: https://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(v=vs.110).aspx

The Remarks section in the link above explains how to resolve this, to quote:

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:

    <pages validateRequest="false" />    

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