简体   繁体   English

.net core 3.1 mvc razorpage 编辑方法 httppost 不起作用?

[英].net core 3.1 mvc razorpage edit method httppost not working?

When I try to submit my form, my request is not reaching the Post-method 'Edit and is returning HTTP Error Code 415 .当我尝试提交表单时,我的请求未到达 Post-method 'Edit 并返回 HTTP Error Code 415

my razor page not fire action, i am using metronic theme integration and then not working post method.我的剃须刀页面没有触发操作,我正在使用 metronic 主题集成,然后无法使用 post 方法。
Following is the server-side code:以下是服务器端代码:

[HttpPost]
[ValidateAntiForgeryToken]        
public async Task<IActionResult> Edit(int id, [FromForm] Firma firma)
{
    //code here[enter image description here][1]
}

And following is the client side code:以下是客户端代码:

@model satinalma.Models.Firma
@{
    ViewData["Title"] = "Edit";
}
<form asp-action="Edit">
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <input type="hidden" asp-for="Id" />
    <div class="form-group">
        <label asp-for="Baslik" class="control-label"></label>
        <input asp-for="Baslik" class="form-control" />
        <span asp-validation-for="Baslik" class="text-danger"></span>
    </div>
    <div class="form-group">
        <input type="submit" value="Save" class="btn btn-primary" />
    </div>
</form>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

You've got the asp-action tag helper for the method, but not one for the controller.您已经获得了用于该方法的 asp-action 标签助手,但没有用于控制器的标签助手。 Try adding that and see if it routes properly.尝试添加它,看看它是否正确路由。

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-3.1 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-3.1

暂无
暂无

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

相关问题 选定的复选框未显示在 asp.net core mvc 3.1 的 HttpPost 操作方法中 - Selected Checkboxes are not showing up in the HttpPost action method in asp.net core mvc 3.1 HTTP 错误 405 | [HttpPost] ASP.NET MVC 核心 3.1 - HTTP ERROR 405 | [HttpPost] ASP.NET MVC Core 3.1 Httppost 和 httpput 被 .net 核心 3.1 中的 CORS 阻止 - Httppost and httpput blocked by CORS in .net core 3.1 RazorPage 中默认 HtmlHelper 的扩展方法 (ASP.NET CORE) - Extension Method for Default HtmlHelper in RazorPage (ASP NET CORE) ASP.Net Core 3.1:控制器方法总是从 HttpPost 调用接收 NULL 参数 - ASP.Net Core 3.1: Controller method always recieves NULL parameter from HttpPost call 带有 [HTTPPost] 的 .Net Core 3.1 API Action 方法返回 405 并带有错误的响应头允许 - .Net Core 3.1 API Action method with [HTTPPost] returns 405 with incorrect Response Header Allow 在 .net 核心 3.1 web Z8A5DA52ED1264417D35AZE 应用程序中将 model 发送到 HttpPost 方法时出现问题 - Problem sending model to HttpPost method in a .net core 3.1 web api application 如何使用 JavaScript 从 .NET Core 3.1 正确调用 HttpPost 方法避免 400 错误 - How do I use JavaScript to properly call a HttpPost method from .NET Core 3.1 avoiding the 400 error "ASP.NET Web App CORE:未调用控制器中的 HttpPost 编辑方法" - ASP.NET Web App CORE: the HttpPost Edit Method in Controller not being called 带有 Web API 路由的 .NET Core 3.1 MVC 不起作用 - .NET Core 3.1 MVC with Web API Routing not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM