Я подтвердил, что почтовый запрос к методу действия в контроллере правильный.Когда я устанавливаю точку останова в контроллере, она не срабатывает.Почему это происходит?Я верю, что мой HTML также верен.
ManageClients.cshtml
@using OPP.Web.ViewModels
@model AdminViewModel
@{
ViewBag.Title = "Manage Clients";
}
<h2>Manage Clients</h2>
<table class="table table-bordered table-responsive table-hover">
<tr>
<th>Client ID </th>
<th>Client Name </th>
<th>Client Expiration Date</th>
<th>Facility Code</th>
<th>Client Email</th>
<th>Is the client Active?</th>
</tr>
@foreach (Client client in Model.Clients)
{
<tr>
<td>@Html.ActionLink(client.client_id.ToString(), "Index", "Clients", new { id = client.client_id }, null)</td>
<td>@client.Name</td>
<td>
@client.ExpireDate
@if (client.ExpireDate != null)
{
using (Html.BeginForm("UpdateExpireTime", "Clients"))
{
<label>Add days (28 is 4 weeks)</label>
@Html.TextBoxFor(m => m.Client.Days, new { @class = "form-control" })
@Html.TextBoxFor(m => m.Client.client_id, new { @Value = client.client_id, @class = "hidden" })
@*<input type="button" value="Delete" onclick="location.href='@Url.Action("Delete", "Workouts")'" />*@
<input type="submit" value="Update Time" />
}
}
</td>
<td>@client.FacilityCode</td>
<td>@client.Email</td>
<td>@client.Active</td>
<td>
@using (Html.BeginForm("Delete", "Clients"))
{
@Html.TextBoxFor(m => m.Client.client_id, new { @Value = client.client_id, @class = "hidden" })
@*<input type="button" value="Delete" onclick="location.href='@Url.Action("Delete", "Workouts")'" />*@
<input type="submit" value="Revoke access" />
}
</td>
</tr>
}
</table>
<h2>Manually make a client active (28 day subscription)</h2>
@using (Html.BeginForm("ManualActiveAdd", "Clients",FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<label>Client ID:</label>
@Html.TextBoxFor(m => m.Client.client_id, new { @class = "form-control" })
@*<input type="button" value="Delete" onclick="location.href='@Url.Action("Delete", "Workouts")'" />*@
<input type="submit" value="Give 4 week access" />
}
Контроллер клиентов
[HttpPost]
public ActionResult Delete(Client client)
{
if(Request.IsAuthenticated)
{
if(User.IsInRole("Superuser"))
{
using(OPPDBContext context = new OPPDBContext())
{
Client nclient = context.Clients.Where(p => p.client_id == client.client_id).FirstOrDefault();
nclient.Active = false;
nclient.IsAssessment = false;
nclient.IsSurvey = false;
nclient.ExpireDate = null;
context.Clients.AddOrUpdate(nclient);
}
return RedirectToAction("ManageClients", "Admin");
}
}
return RedirectToAction("AccessDenied", "Error");
}
[HttpPost]
public ActionResult UpdateExpireTime(Client client)
{
if (Request.IsAuthenticated)
{
if (User.IsInRole("Superuser"))
{
using (OPPDBContext context = new OPPDBContext())
{
Client nclient = context.Clients.Where(p => p.client_id == client.client_id).FirstOrDefault();
nclient.ExpireDate = nclient.ExpireDate.Value.AddDays(client.Days);
context.Clients.AddOrUpdate(nclient);
context.SaveChanges();
}
return RedirectToAction("ManageClients", "Admin");
}
}
return RedirectToAction("AccessDenied", "Error");
}
[HttpPost]
public ActionResult ManualActiveAdd(Client client)
{
if (Request.IsAuthenticated)
{
if (User.IsInRole("Superuser"))
{
using (OPPDBContext context = new OPPDBContext())
{
Client nclient = context.Clients.Where(p => p.client_id == client.client_id).FirstOrDefault();
nclient.Active = true;
nclient.IsAssessment = true;
nclient.IsSurvey = true;
nclient.ExpireDate = DateTime.Now.AddDays(28);
context.Clients.AddOrUpdate(nclient);
}
return RedirectToAction("ManageClients", "Admin");
}
}
return RedirectToAction("AccessDenied", "Error");
return View();
}
Если мой пост-запрос / контроллер верен, что может быть возможнобыть проблемой?