当我调用我的webservice witch时,我会得到两个参数:
从客户端(&)检测到具有潜在危险的Request.Path值。
Routeconfig:
config.Routes.MapHttpRoute(
name: "PropertiesSearch",
routeTemplate: "api/property/Search/{category}/{query}",
defaults: new { controller = "Property", action = "Search", category = "common", query = string.Empty }
);
Controllermethod:
[HttpGet]
public SearchResult Search(string category, string query)
{
}
当我使用以下命令调用api时:
/api/property/search/homes/areaId%3D20339%26areaId%3D20015
从客户端(&)检测到具有潜在危险的Request.Path值。
执行此操作:
/api/property/search/homes/?query=areaId%3D20339%26areaId%3D20015
工作正常。
如何解决路由解码问题?
发布于 2013-01-17 05:56:02
斯科特·汉斯曼blogged about this。您可能需要检查web.config中<httpRuntime>
节点的requestPathInvalidCharacters
属性。
就我个人而言,我会避免在uri部分使用这样的字符,而只是将这些值作为查询字符串参数。
https://stackoverflow.com/questions/14359305
复制相似问题