我在使用URL
导航到我的ListPeople
方法时遇到问题。如果我在我的URL
中输入localhost:12345/People?peopleId=405&age=24
,它工作正常;但是,当我将localhost:12345/People?peopleId=405
传入我的URL
时,它会返回404
错误。自定义URL路由处理使用C#控制器的可选参数
404错误消息:
"No HTTP resource was found that matches the request URI'http://localhost:12345/People?peopleId=405'."
我怎样才能改变我的ListPeople
控制器的路由,以便它节选BOTH网址?
控制器
[HttpGet]
[ReturnDescription("List of People")]
[CustomActionName("")]
[Description("List of people for given peopleId and age")]
public ApiResponse<Status, IEnumerable<People>> ListPeople(int peopleId, int? age)
{
return _personProject.ListPeople(peopleId, age);
}
成功URL
localhost:12345/People?peopleId=405&age=24
失败URL
localhost:12345/People?peopleId=405
这个很棒,非常感谢! – ChaseHardin