我在使用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