删除未点击的路线 [英] Delete route not being hit

本文介绍了删除未点击的路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与这个问题进行斗争的时间太长了,现在该寻求帮助了.我的.net核心mvc应用程序的删除路由未命中.其他所有路线(获取",张贴")也都可以正常运行.启动时的路由配置如下:

Being battling this issue for too long now it's time to ask for help. The delete route of my .net core mvc app is not being hit. All other routes (Get, Post) are hit just fine. The route config at startup looks like this:

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller}/{action}/{id?}");
    });

表单提交看起来像这样:

The form submit looks something like this:

    <a class="btn btn-primary" href="~/DisabledRegistrations/Delete/@(Model.Id)">Confirm</a>

控制器方法如下:

[Authorize]
[HttpDelete]
public async Task<IActionResult> Delete(string id)
{
  ...
}

但是用类似的东西来达到目标​​

But hitting that with something like:

https://localhost:8307/DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e

导致:

No webpage was found for the web address: 
https://localhost:8307/DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e

我们在Service Fabric中运行,不确定是否有任何细节.我们的web.config拥有此功能,尽管不确定是否与该上下文相关:

We run in Service Fabric and not sure if there's any particulars to that. Our web.config has this although not sure if it's relevant in that context:

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>

任何尝试尝试的提示都将不胜感激.

Any hints for things to try are greatly appreciated.

更新:

如果我确实确实提交了如下表格:

If I actually do submit a form as follows:

<form asp-controller="DisabledRegistrations" asp-action="Delete" method="delete" asp-route-id="@Model.Id">
    <div class="text-right">
        <button type="submit" class="btn btn-primary">Confirm</button>
        <a class="btn btn-primary" href="~/DisabledRegistrations/Index">Cancel</a>
    </div>
</form>

那我仍然得到:

No webpage was found for the web address: 
https://localhost:8307/DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e?__RequestVerificationToken=CfDJ8KwmDf2MXHlGrC8zIIntu4IV_83R9jSBwPqk3w8Ymq2VoBnQHN8lxEOHqMUfJwtxX-HLZwr6AWw8uKiVaSz7l-CZjPzZ_IxJhRh31MYiwbgsJzLcQMvrHWGd_sueZ8OLKbRAoYGeVHLfVfkjac-TCaLE9CoOYSCyhY4EDtrFhiLVY3_3h-bJTSLYTT2E7qXcvA

推荐答案

[HttpDelete]

是一个类似post的动词,您不是从仅执行http get的链接中进行http删除,因此它与您的路线不匹配.要删除动词,您将必须使用ajax并指定动词.

is a verb like post, you are not doing http delete from your link that is just doing http get therefore it doesn't match your route. to do delete verb you would have to use ajax and specify the verb.

您不提交表单,只显示一个链接的元素,因此不会删除动词

you are not submitting a form, you only show an a element that links therefore get not delete verb

这篇关于删除未点击的路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆