【发布时间】:2015-09-01 05:29:11
【问题描述】:
我在 ApiController 中定义了一个方法。当方法定义如下:
public IEnumerable<QuestionResponse> Get()
一切都很好。但是我想将参数传递给该方法,但是当我将该方法定义为
public IEnumerable<QuestionResponse> Get(int parid)
响应是 405“请求的资源不支持 http 方法 'GET'”。
当没有为该方法定义参数时,这两个 url 都会被路由到该方法:
/api/questionresponse/224809
/api/questionresponse
但是当我为该方法定义一个参数时,这两个 url 都会导致 405 。
帮助?
FWIW
- 请求是从同一项目中提供的页面上的某个 jquery 发出的
- 我迄今为止所做的一切都基于此文本http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api。
- 我在这里描述的结果都是在 Visual Studio 2015 中运行时的结果。
【问题讨论】:
-
尝试将参数名称从 parid 更改为 id,它应该可以工作
标签: c# asp.net-mvc asp.net-web-api