I'm getting this error in an MVC app:
The view 'Index' or its master was not found. The following locations were searched:
~/Views/User/Index.aspx
~/Views/User/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
I don't understand why it's coming up; I'm not trying to navigate to an Index view; I'm trying to navigate to a ChangeExpiredPassword route. The code for the ChangeExpiredPassword controller action is executing, but as soon as control passes out of that method, this error is thrown from the internals of MVC. I have no idea why we're trying to redirect to Index all of a sudden. I don't know what code would be relevant to share but I can add code upon request. Thanks!
edit: here is how we are getting to ChangeExpiredPassword, this is from a UserController
class:
[HttpPost]
public ActionResult Index(LogOnModel model, string returnUrl)
{
...
if (pwExpirationDate < DateTime.Now)
{
return ChangeExpiredPassword();
}
...
}
and here is the ChangeExpiredPassword itself, minus some HTML building code:
[HttpGet]
public ActionResult ChangeExpiredPassword()
{
ActionResult actionResult = null;
try
{
ContentViewModel viewModel = new ContentViewModel();
Form form = new Form();
form.Method = FormMethod.Post;
form.Action = "User/ChangeExpiredPassword";
// this is where we build some HTML for the Change Expired Password view
viewModel.ContentControls.Add(form);
actionResult = View(viewModel);
}
catch (Exception ex)
{
HandleException(ex);
actionResult = Error();
}
return actionResult;
}
Index
action and it's returning a view then, well, it'll look for anIndex
view. – DavidChangeExpiredPassword()
? What does it return? It sounds like it's returning aView()
. So I guess the question becomes... What do you want to happen at the end of thisIndex
action? What should be returned to the user? – David