我正在做一个小页面,你可以在那里创建用户,修改他们的密码和删除他们。创建工作很好,但删除和修改密码不响应点击任何方式。它通过 Postman 工作正常。可能是什么问题?
@page
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "Shared/_MonitoringLayout";
ViewData["PageTitle"] = "users";
}
@section MainBlock {
@{
if (@Model.Error != null)
{
<div>
<span style="color: red">@($"Error: {Model.Error}")</span>
</div>
}
else
{
<div>
<table style="max-width: 70%" class="m_table">
<thead class="m_table_header">
<tr>
<th style="width: 5%">
Id
</th>
<th style="width: 15%">
Name
</th>
<th style="width: 15%">
Login
</th style="width: 25%">
<th>
Action
</th>
</tr>
</thead>
<tbody>
@foreach (var rootUser in Model.RootUsers)
{
<tr>
<td>
@rootUser.Id
</td>
<td>
@rootUser.DisplayName
</td>
<td>
@rootUser.Login
</td>
<td>
<from method="post">
<div>
<lable>NewPassword:</lable>
<input type="password" name="password" required />
<input asp-page-handler="ChangePassword" value="Change" type="submit"/>
</div>
</from>
<from method="post">
<input asp-page-handler="DeleteUser" asp-route-id="@rootUser.Id" value="Delete" type="submit"/>
</from>
</td>
</tr>
}
</tbody>
</table>
</div>
<br />
}
<div>
<form method="post">
<h1>Create</h1>
<div class="input-container">
<input asp-for="CreateAccountRequest.DisplayName" type="text" required />
<lable asp-for="CreateAccountRequest.DisplayName">Name</lable>
</div>
<div class="input-container">
<input asp-for="CreateAccountRequest.Login" type="text" value="root" readonly/>
<lable asp-for="CreateAccountRequest.Login">Login</lable>
</div>
<div>
<input asp-for="CreateAccountRequest.Password" type="password" required/>
<lable asp-for="CreateAccountRequest.Password">Password</lable>
</div>
<button asp-page-handler="create" type="submit">Create</button>
</form>
</div>
}
};
[IgnoreAntiforgeryToken]
public class ServiceUsersModel : PageModel
{
public List<InternalAccountResponse> RootUsers { get; private set; }
[BindProperty]
public InternalCreateAccountV2Request CreateAccountRequest { get; set; }
protected async override Task<IActionResult> OnGet()
{
..Do
}
public async Task<IActionResult> OnPostCreateAsync()
{
..Do
}
public async Task<IActionResult> OnPostDeleteUserAsync(long id)
{
..Do
}
public async Task<IActionResult> OnPostChangePasswordAsync(string password)
{
..Do
}
}
我试着通过chrome中的开发者工具和调试来跟踪请求,请求就是不会消失,尽管形成了formaction = "/monitoring/serviceusers?id = 536&handler = deleteUser "来删除和/monitoring/serviceusers?handler = ChangePassword"来更改密码。如果你通过 Postman 发送这些请求,它们就会到达服务。
1条答案
按热度按时间hgncfbus1#
<from>
标记应使用<form>
标记