HTTP ERROR : 405(This page isn't working) When I Refresh The Page(ASP.Net Core MVC)
HTTP ERROR : 405(This page isn't working) When I Refresh The Page(ASP.Net Core MVC)
我正在开发一个 ASP.Net Core MVC 网站,我在该网站上有一个包含数据表的页面,该页面上的每条记录都有一个按钮,可以显示该记录的更多详细信息。当我单击该详细信息按钮时,它工作正常但是当我刷新详细信息页面时,我遇到了上述错误。据我所知,没有任何调试错误。请帮帮我!!
这是包含数据表的页面的代码:
@model Derawala.Models.ViewModels.ParentForApply
@{
Layout = "_Layout";
}
<form method="post">
<div class="container p-3">
<div class="row pt-4">
<div class="col-6">
<h2 class="text-success">Application List</h2>
</div>
</div>
<br /><br />
@if (Model.AppList.Any())
{
<table id="myTable" class="table table-hover align-middle table-bordered table table-striped" style="width:100%">
<thead>
<tr>
<th class="text-center">
Applicant Name
</th>
<th class="text-center">
Contact No
</th>
<th class="text-center">
Institute Name
</th>
<th class="text-center">
Institute Contact
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var obj in Model.AppList)
{
<tr>
<td class="text-center text-primary" style="font-weight:bold;">@obj.FirstName</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.Contact</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.Institute</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.InstCnt</td>
<td class="text-center">
<div class="w-75 btn-group" role="group">
<button type="submit" asp-action="Details" asp-route-Id="@obj.Id" class="btn btn-primary mx-2">
<i class="fas fa-list"></i>
</button>
<a asp-action="Delete" asp-route-Id="@obj.Id" class="btn btn-danger mx-2">
<i class="fas fa-trash-alt"></i>
</a>
</div>
</td>
</tr>
}
</tbody>
</table>
}
else
{
<p>No Application Exists!</p>
}
</div>
</form>
这是包含数据表的页面视图
当我点击 Details 按钮(蓝色按钮)时,它会转到如下所示的详细信息页面:
这是详细信息页面的代码:
@model Derawala.Models.ViewModels.ParentForApply
@{
ViewData["Title"] = "Details";
Layout = "_Layout";
}
<form method="post">
<input asp-for="@Model.Apply.PofId" hidden />
<div class="container backgroundWhite pt-4">
<div class="card" style="border:1px solid #000000; ">
@*<div class="card-header bg-dark text-light ml-0 row container" style="border-radius: 0px;">*@
<div class="card-header" style="background-color:black;">
<div class="row">
<div class="col-12 col-md-6 align-self-start">
<h1 class="text-white">@Model.Apply.FirstName @Model.Apply.LastName</h1>
</div>
<div class="col-12 col-md-6 align-self-end">
<h1 class="text-warning">Application Id :@Model.Apply.AppId</h1>
</div>
</div>
</div>
<div class="card-body">
<div class="container rounded p-2">
<div class="row">
<div class="col-12 col-lg-4 p-1 text-center">
<img src="@WC.ImagePath[0]@Model.Apply.Photo" class="rounded w-25" />
</div>
<div class="col-12 col-lg-8">
<div class="row pl-3">
<div class="col-12">
<span class="badge p-3 border" style="background-color:lightpink">@Model.Apply.Qualification</span>
<span class="badge p-3 border" style="background-color:lightskyblue">@Model.Apply.BankName</span>
<h3 class="text-success"></h3>
<p class="text-secondary">@Model.Apply.Description</p>
</div>
</div>
<div class="row pl-3">
<div class="col-12">
Download Id Proof : <button type="submit" class="btn-primary" asp-route-id="@Model.Apply.PofId" asp-action="DownloadFile">Download</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer bg-dark">
<div class="row">
<div class="col-12 col-md-6 ">
<a asp-action="RemoveFromCart" class="btn btn-primary btn-square form-control btn-lg" style="height:50px;">Donate Now <i class="fas fa-hand-holding-medical"></i></a>
</div>
<div class="col-12 col-md-6">
<button type="submit" asp-action="" class="btn btn-danger form-control btn-lg" style="height:50px;">Delete This Application <i class="fas fa-trash-alt"></i></button>
</div>
</div>
</div>
</div>
</div>
</form>
这是详情页面的视图:
当我刷新这个详细信息页面时,它给我这个 HTTP 405 错误:
您的详细信息操作可能具有 [HttpPost] 属性,您使用提交按钮调用它。但是当您尝试刷新浏览器时调用 Get 方法。因此,您必须从详细信息操作中删除 [HttpPost],或者使用 [HttpGet] 创建另一个操作。
我正在开发一个 ASP.Net Core MVC 网站,我在该网站上有一个包含数据表的页面,该页面上的每条记录都有一个按钮,可以显示该记录的更多详细信息。当我单击该详细信息按钮时,它工作正常但是当我刷新详细信息页面时,我遇到了上述错误。据我所知,没有任何调试错误。请帮帮我!!
这是包含数据表的页面的代码:
@model Derawala.Models.ViewModels.ParentForApply
@{
Layout = "_Layout";
}
<form method="post">
<div class="container p-3">
<div class="row pt-4">
<div class="col-6">
<h2 class="text-success">Application List</h2>
</div>
</div>
<br /><br />
@if (Model.AppList.Any())
{
<table id="myTable" class="table table-hover align-middle table-bordered table table-striped" style="width:100%">
<thead>
<tr>
<th class="text-center">
Applicant Name
</th>
<th class="text-center">
Contact No
</th>
<th class="text-center">
Institute Name
</th>
<th class="text-center">
Institute Contact
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var obj in Model.AppList)
{
<tr>
<td class="text-center text-primary" style="font-weight:bold;">@obj.FirstName</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.Contact</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.Institute</td>
<td class="text-center text-primary" style="font-weight:bold;">@obj.InstCnt</td>
<td class="text-center">
<div class="w-75 btn-group" role="group">
<button type="submit" asp-action="Details" asp-route-Id="@obj.Id" class="btn btn-primary mx-2">
<i class="fas fa-list"></i>
</button>
<a asp-action="Delete" asp-route-Id="@obj.Id" class="btn btn-danger mx-2">
<i class="fas fa-trash-alt"></i>
</a>
</div>
</td>
</tr>
}
</tbody>
</table>
}
else
{
<p>No Application Exists!</p>
}
</div>
</form>
这是包含数据表的页面视图
@model Derawala.Models.ViewModels.ParentForApply
@{
ViewData["Title"] = "Details";
Layout = "_Layout";
}
<form method="post">
<input asp-for="@Model.Apply.PofId" hidden />
<div class="container backgroundWhite pt-4">
<div class="card" style="border:1px solid #000000; ">
@*<div class="card-header bg-dark text-light ml-0 row container" style="border-radius: 0px;">*@
<div class="card-header" style="background-color:black;">
<div class="row">
<div class="col-12 col-md-6 align-self-start">
<h1 class="text-white">@Model.Apply.FirstName @Model.Apply.LastName</h1>
</div>
<div class="col-12 col-md-6 align-self-end">
<h1 class="text-warning">Application Id :@Model.Apply.AppId</h1>
</div>
</div>
</div>
<div class="card-body">
<div class="container rounded p-2">
<div class="row">
<div class="col-12 col-lg-4 p-1 text-center">
<img src="@WC.ImagePath[0]@Model.Apply.Photo" class="rounded w-25" />
</div>
<div class="col-12 col-lg-8">
<div class="row pl-3">
<div class="col-12">
<span class="badge p-3 border" style="background-color:lightpink">@Model.Apply.Qualification</span>
<span class="badge p-3 border" style="background-color:lightskyblue">@Model.Apply.BankName</span>
<h3 class="text-success"></h3>
<p class="text-secondary">@Model.Apply.Description</p>
</div>
</div>
<div class="row pl-3">
<div class="col-12">
Download Id Proof : <button type="submit" class="btn-primary" asp-route-id="@Model.Apply.PofId" asp-action="DownloadFile">Download</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer bg-dark">
<div class="row">
<div class="col-12 col-md-6 ">
<a asp-action="RemoveFromCart" class="btn btn-primary btn-square form-control btn-lg" style="height:50px;">Donate Now <i class="fas fa-hand-holding-medical"></i></a>
</div>
<div class="col-12 col-md-6">
<button type="submit" asp-action="" class="btn btn-danger form-control btn-lg" style="height:50px;">Delete This Application <i class="fas fa-trash-alt"></i></button>
</div>
</div>
</div>
</div>
</div>
</form>
这是详情页面的视图:
您的详细信息操作可能具有 [HttpPost] 属性,您使用提交按钮调用它。但是当您尝试刷新浏览器时调用 Get 方法。因此,您必须从详细信息操作中删除 [HttpPost],或者使用 [HttpGet] 创建另一个操作。