I am confused by this. I use a razor with MVC 3, and I have a problem with one view per action.
[HttpGet] [ActionName("Unsubscribe")] public ActionResult UnsubscribeGet(string maskedId) { return View("Unsubscribe", maskedId); }
The Unsubscribe.cshtml view is in the correct view folder.
Route
routes.MapRoute( "", // Route name "Unsubscribe/{maskedId}", // URL with parameters new { controller = "Account", action = "Unsubscribe" });
When you go to the next URL "/ Unsubscribe / db94fddb", the action starts, and then when you try to find the view, the following error is displayed.
The Unsubscribe view or its wizard was not found or the viewer does not support the locations found. The following locations were searched:
~ / Views / Account / Unsubscribe.aspx
~ / Views / Account / Unsubscribe.ascx
~ / Views / Shared / Unsubscribe.aspx
~ / Views / Shared / Unsubscribe.ascx
~ / Views / Account / db94fddb.master
~ / Views / Shared / db94fddb.master
~ / Views / Account / db94fddb.cshtml
~ / Views / Account / db94fddb.vbhtml
~ / Views / Shared / db94fddb.cshtml
~ / Views / Shared / db94fddb.vbhtml
Note that it does not look for the cshtml extension when searching for Unsubscribe, but when searching for db94fddb
This only happens with this view, completely at a loss how to fix it.
** EDIT **
Found,
I used System.String as a model. For some reason, it made him explode.
I changed it to @model UnsubscribeViewModel
[HttpGet] [ActionName("Unsubscribe")] public ActionResult UnsubscribeGet(string maskedId) { return View("Unsubscribe", new UnsubscribeViewModel { MaskedId = maskedId } ); }
Although it works now, I still donโt know why it didnโt work before. I have my views for compiling on an assembly, so there were no compiler errors.
I would like to know what is going on here.