[英]How to match url to controller action
I'm having difficulty getting my my controller action, as this is currently matching the default route (I'm using a typical default route configuration) 我在执行控制器操作时遇到了困难,因为该操作当前与默认路由匹配(我正在使用典型的默认路由配置)
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
Why doesn't my url get routed to this controller action? 为什么我的网址没有路由到该控制器动作?
My typescript 我的打字稿
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let update = new CollectionUpdate();
update.collectionID = Number(this.collectionID);
update.collectionName = "new name";
let url = "/api/Collections/RenameCollection/";
let json = JSON.stringify(update);
debugger;
return this.http
.patch(url, json, { headers: headers })
.map(res => res.json())
.subscribe(
result => {
this.onRename(result as CollectionUpdate)
});
My controller action 我的控制器动作
[HttpPatch]
public Task<CollectionUpdate> RenameCollection([FromBody]CollectionUpdate update)
{
return Task.FromResult<CollectionUpdate>(new CollectionUpdate());
}
Changing it to a put operation worked. 将其更改为放置操作即可。 I guess I'll just roll with that. 我想我会继续讲下去。
[HttpPut("[action]")]
public Task<CollectionUpdate> RenameCollection([FromBody]CollectionUpdate update)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.