I am new to this and facing an issue with my web service .asmx. It is working fine with the Visual Studio test page .asmx, but it returns a 500 error to the client.
The problem arises when I include HTML in the payload from the client, causing the server to fail. Interestingly, the Visual Studio test page works seamlessly with HTML. Any suggestions or assistance would be greatly appreciated. Thank you!
Web Service
.asmx
[WebMethod, ValidateInput(false)]
public string HelloWorld(string input)
{
return "Hello World";
}
Server web.config
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime requestValidationMode="2.0"/>
<pages validateRequest="false"
controlRenderingCompatibilityVersion="4.0"/>
</system.web>
ajax
$.ajax({
type: "POST",
url: "http://localhost:62093/tMt_webService1In.asmx/HelloWorld",
data: "{ 'mail': '" + bodyout + "' }",
contentType: "application/json; charset=utf-8",
datatype: "json",
success: function(responseFromServer) {
alert(responseFromServer.d)
},
error: function(responseFromServer) {
alert("error " + responseFromServer.lastError)
}
});