Я получаю сообщение о том, что представление Обновление не найдено, я хотел показать представление TaskDetail, а не представление обновления ...
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Update(int taskid, string status)
{
if (!status.Equals("closed", StringComparison.OrdinalIgnoreCase) &&
!status.Equals("opened", StringComparison.OrdinalIgnoreCase))
ModelState.AddModelError("", "incorrect status, please try again");
if (!this.ModelState.IsValid)
return TaskDetail(taskid);
if (status.Equals("Closed", StringComparison.OrdinalIgnoreCase))
_service.CloseTask( taskid, true);
else
_service.CloseTask(taskid, false);
this.FlashInfo("success, task status has been updated...");
return RedirectToAction("TaskDetail");
}
Исключение:
$exception{"The view 'Update' or its master was not found. The following locations were searched:\r\n~/Areas/Tasks/Views/TaskManager/Update.aspx\r\n~/Areas/Tasks/Views/TaskManager/Update.ascx\r\n~/Areas/Tasks/Views/Shared/Update.aspx\r\n~/Areas/Tasks/Views/Shared/Update.ascx\r\n~/Views/TaskManager/Update.aspx\r\n~/Views/TaskManager/Update.ascx\r\n~/Views/Shared/Update.aspx\r\n~/Views/Shared/Update.ascx"} System.Exception {System.InvalidOperationException}
Сведения о задаче: (это внутри того же контроллера)
[HttpGet]
public ActionResult TaskDetail(int taskid)
{
var loggedonuser = _repo.GetCurrentUser();
var companies = _repo.All<Company>();
var users = _repo.All<User>();
var task = _repo.Single<InstructionTask>
(x => x.TaskID == taskid && (x.CompanyID == loggedonuser.CompanyID || x.AssignedTo.Contains(loggedonuser.CompanyType.ToString())));
var dto = new TaskDTO
{
TaskID = task.TaskID,
Title = task.Title,
Description = task.Description,
DateCreated = task.DateCreated,
IsClosed = task.IsClosed,
CompanyID = companies.Where(y => task.CompanyID == y.CompanyID).SingleOrDefault().Identifier,
};
var checkedtags = TaskTagsHelper.GetTags(task.AssignedTo);
var t = TaskTagsHelper.GetPanelTags();
if (checkedtags != null) //if tags are present only then tick them off...
{
foreach (var item in t.Keys.ToList())
{
if (checkedtags.Any(x => x == item))
t[item] = true;
}
}
dto.AvailableTags = t;
if (task.DueDate.HasValue)
dto.DueDate = task.DueDate.Value;
var comments = _repo.All<TaskComment>()
.Where(x => x.TaskID == task.TaskID)
.OrderByDescending(x => x.Timestamp)
.Select(x => new TaskCommentDTO
{
Comment = x.Comment,
Timestamp = x.Timestamp,
CompanyID = companies.Where(y => x.CompanyID == y.CompanyID).SingleOrDefault().Identifier,
UserID = users.Where(y => x.UserID == y.UserID).SingleOrDefault().Login,
Type = EnumHelper.Convert<TaskCommentType>(x.Type)
});
dto.AllComments = comments;
return View(new TaskViewModel
{
TaskDetail = dto,
NewComment = new TaskCommentDTO()
});
}
Я обнаружил исключение здесь, в моем базовом контроллере:
//Generic methods/ controllers/ attributes will be applied here...
protected override void OnException(ExceptionContext filterContext)
{
//dont interfere if the exception is already handled
if (filterContext.ExceptionHandled)
return;
//let the next request know what went wrong
filterContext.Controller.TempData["exception"] = filterContext.Exception;
//logg exception
//set up redirect to my global error handler
filterContext.Result = new ViewResult { ViewName = "~/Views/Error/PublicError.aspx" };
//advise subsequent exception filters not to interfere and stop
// asp.net from showing yellow screen of death
filterContext.ExceptionHandled = true;
//erase any output already generated
filterContext.HttpContext.Response.Clear();
}