点击链接时出错

时间:2014-09-16 12:12:16

标签: asp.net asp.net-web-api

我使用knockout' s observable

动态地将url绑定到我的href标签
 <a data-bind="attr: { href: URlPath }">See this</a>

我已声明可观察如下

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

当我点击链接时出现错误

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

我尝试在web.config中使用下面但没有帮助。我正在使用WebApi。

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

我也没有任何特殊字符,但我仍然遇到此错误。有人能帮助我吗?

更新

这是我在webapi中的方法

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

1 个答案:

答案 0 :(得分:1)

您的url错误,应该如下you are using & after Action Name

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