【发布时间】:2017-06-05 20:21:36
【问题描述】:
在这个 webAPI 控制器中,Action PSWS 返回 404。它之前工作正常,但现在显示 404。除了与不同实体相关的更多控制器之外,代码没有任何变化。调试器只是没有捕获任何东西或在断点处停止,我已经尝试了知识或资源中的所有内容以了解它为什么显示 404 ,但没有任何效果。
我正在通过以下网址访问此操作
http://localhost:43827/api/Pss/PSWS/cs/b3dc86d8-9b55-4c7e-95f3-7bab0908510d/ps/1eaaaa5e-dd32-4d29-9b85-16c1eb7890f4/pss/6af508be-c2ca-4d00-aeb4-dd87cabf72d4/quantity/4/SerialPrefix/FP_P/StartFrom/21-11-2017/Expires/21-11-2019
任何帮助或指针将不胜感激:)
namespace API.Controllers
{
[RoutePrefix("api/Pss")]
public class myEntityController : ApiController
{
private localEntities db = new localEntities();
[HttpGet]
[Route("")]
// GET: api/myEntity
public async Task<IHttpActionResult> GetmyEntity(){ return OK("OK")}
[HttpGet]
[Route("{keys:guid}")]
// GET: api/myEntity/1f7dc74f-af14-428d-aa31-147628e965b2
[ResponseType(typeof(myEntity))]
public async Task<IHttpActionResult> GetmyEntity(Guid keys){ return OK("OK")}
// PUT: api/myEntity/1f7dc74f-af14-428d-aa31-147628e965b2
[HttpPut]
[Route("{keys:guid}", Name = "PutmyEntity")]
[ResponseType(typeof(void))]
public async Task<IHttpActionResult> PutmyEntity(Guid keys){ return OK("OK")}
// POST: api/myEntity
[HttpPost]
[Route("", Name = "PostmyEntity")]
[ResponseType(typeof(myEntity))]
public async Task<IHttpActionResult> PostmyEntity(Guid keys,myEntity entity){ return OK("OK")}
[HttpGet]
[Route("psws/cs/{cpKeys:guid}/ps/{prkKeys:guid}/pss/{prkSKeys:guid}/quantity/{quantity:int}/SerialPrefix/{_SerialPrefix:length(3,20)}/StartFrom/{start:DateTime}/Expires/{end:DateTime}"]
[ResponseType(typeof(JObject))]
public IHttpActionResult PSWS(Guid cpKeys, Guid prkKeys, Guid prkSKeys, int quantity, string _SerialPrefix, DateTime start, DateTime end)
{
return Ok("kill");
}
}
}
【问题讨论】:
标签: c# asp.net-web-api asp.net-web-api-routing