【发布时间】:2017-05-19 04:00:06
【问题描述】:
与这个问题作斗争太久了,现在是时候寻求帮助了。我的 .net core mvc 应用程序的删除路线没有被击中。所有其他路线(获取,发布)都很好。启动时的路由配置如下:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}");
});
表单提交看起来像这样:
<a class="btn btn-primary" href="~/DisabledRegistrations/Delete/@(Model.Id)">Confirm</a>
控制器方法如下所示:
[Authorize]
[HttpDelete]
public async Task<IActionResult> Delete(string id)
{
...
}
但是用类似的东西来解决这个问题:
https://localhost:8307/DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e
结果:
No webpage was found for the web address:
https://localhost:8307/DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e
我们在 Service Fabric 中运行,但不确定是否有任何细节。我们的 web.config 有这个,但不确定它是否与该上下文相关:
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
非常感谢任何有关尝试的提示。
更新:
如果我确实提交了如下表格:
<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
【问题讨论】:
-
提交是否使用了DELETE动词?我不认为删除对表单的方法属性有效吗?
-
它在 VS 中显示为方法属性的有效选项。
-
是的,我不会相信的。相信浏览器在请求检查期间告诉你的内容:stackoverflow.com/questions/5162960/…
-
hmmm...你说得对,fiddler 显示它正在执行 GET:GET /DisabledRegistrations/Delete/f17dff6b3fcd43ba89eab4bbad5c992e?...
-
让它使用 POST 动词和 Delete 操作。现在就足够了。感谢您的帮助!
标签: asp.net-core asp.net-mvc-routing asp.net-core-mvc azure-service-fabric asp.net-core-1.0