**Have a very simple web API:
WebApiConfig.cs:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional});
I can make calls to this web api calling via my data service controller:
[HttpGet]
public HttpResponseMessage GetUsers(string id)
{
var cl = _SecurityRepository.GetUsers(id);
return Request.CreateResponse(HttpStatusCode.OK, cl);
}
Logic is very simple: Searches the DB for any last names that start with the last three letter in id
The call:
The Results:
[
{
"userID": "DLopez",
"firstName": "Don",
"lastName": "Lopez",
"department": "Information Technology"
},
{
"userID": "SLOPER",
"firstName": "Steve",
"lastName": "Loper",
"department": "First Services"
},
{
"userID": "DLOPES",
"firstName": "Davey",
"lastName": "Lopes",
"department": "Public Info"
}
]
It all works great. Yeah! However, in one circumstance I get a resource cannot be found error with this call:
I can use id=can, cone, com, etc,... There are no problems with any of those api calls. They all work great. As soon as I search on con -> resource cannot be found! Does anyone have a clue? I'm lost.
答案 0 :(得分:2)
Yep, "con" is a reserved word and not allowed. The workaround is to include the following under <system.web>
in your Web.config.
<httpRuntime relaxedUrlToFileSystemMapping="true" />
Taken from this answer.