James
James

Reputation: 1945

Getting error while clicking on link

I am binding url to my href tag dynamically using knockout's observable

 <a data-bind="attr: { href: URlPath }">See this</a>

I have declared observable as below

       this.URlPath = ko.observable("http://mysite/api/MyMethod&Param1=0000333&Param2=0000000002&Param3=0000000001");

When i click on link i get error

A potentially dangerous Request.Path value was detected from the client (&). 
[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (&).]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9561124
System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53

I try to use below in web.config but didnt helped. I am using WebApi.

 <httpRuntime targetFramework="4.5"  requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?"/>

I dont have any special characters as well but still i get this error. Can someone help me?

Update

Here is my method in webapi

[ActionName("MyMethod")]
[AcceptVerbsAttribute("GET", "POST")]
[HttpPost]
public HttpResponseMessage MyMethod(string Param1, string Param2, string Param3)
{
      //some logic
}

Upvotes: 0

Views: 629

Answers (1)

Amit
Amit

Reputation: 15387

Your url is wrong it should be as below, you are using & after Action Name

this.URlPath = ko.observable("http://mysite/api/MyMethod?Param1=0000333&Param2=0000000002&Param3=0000000001");

Upvotes: 1

Related Questions