简体   繁体   English

如何在 ASP.NET Core MVC 中调用具有 HttpDelete 属性的端点?

[英]How to call an endpoint with HttpDelete attribute in ASP.NET Core MVC?

As usual we are using Http.ActionLink or 'a' tag with tag helpers to call an endpoint and they send Post request.像往常一样,我们使用 Http.ActionLink 或带有标签助手的“a”标签来调用端点并发送 Post 请求。 How can I reach the api/models/5 [HttpDelete] by call from the view?如何通过视图调用到达 api/models/5 [HttpDelete]?

Browsers only support HTTP GET and HTTP POST verbs when using HTML.使用 HTML 时,浏览器仅支持HTTP GETHTTP POST动词。 You can use other verbs ( DELETE , PUT etc) from JavaScript however (via fetch or XmlHttpRequest ).但是,您可以使用 JavaScript 中的其他动词( DELETEPUT等)(通过fetchXmlHttpRequest )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ajax类型要求[HttpDelete] Asp.Net MVC - type of ajax calls for [HttpDelete] Asp.Net MVC ASP.NET Core 3 MVC端点路由和按路由定位 - ASP.NET Core 3 MVC endpoint routing and localization by route 在 ASP.Net Core 2.2 MVC 中使用 Endpoint-Routing 时如何正确覆盖 IUrlHelper? - How top correctly override the IUrlHelper while using Endpoint-Routing in ASP.Net Core 2.2 MVC? 在ASP.NET Core MVC中无法调用具有类参数带有[FromBody]属性的类的API Post方法 - Unable to call API Post Method that has a class parameter with [FromBody] attribute in asp.net core mvc 如何每隔 X 小时自动调用 ASP.NET Core 端点? - How can I automatically call an ASP.NET Core endpoint each X hours? ASP.NET Core 5.0 Web API 在尝试使用 HttpDelete 删除记录时抛出错误 405 - ASP.NET Core 5.0 Web API throws error 405 when trying to delete record using HttpDelete 基于角色的授权属性在 ASP.NET Core MVC 中不起作用 - Role based authorization attribute not working in ASP.NET Core MVC 如何在 asp.net MVC 中调用 API - How to call API in asp.net MVC 如何在运行时重新加载自定义属性? ASP.NET核心MVC - How to reload a Custom Attribute during run-time? ASP.NET Core MVC Asp.net 核心 mvc 如何通过 razor 设置属性“必需” - Asp.net core mvc how to set attribute 'required' via razor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM