May 12, 2012 at 11:04 AM
Edited May 12, 2012 at 11:57 AM
I just started looking into DisplayModes feature of ASP.NET MVC 4. I've looked at it in the preview version but it has changed a lot in the beta as far as I can tell.
The registery point for DispalyModes is now System.Web.WebPages.DisplayModeProvider.Instance.Modes property which is type of IList<IDisplayMode>. When I look into this collection, there are two DisplayModes by default and both
of them are type of System.Web.WebPages.DefaultDisplayMode. The one of them is for mobile whose index is 0. The second one is empty.
Based on that, if I do the following inside the Application_Start:
I get the so-called ASP.NET MVC 404:
System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
and this error message lies because ~/Views/Home/Index.cshtml
is present. As for my questions:
- Is this an expected behavior?
- Is the DisplayMode I've removed required for Razor views to function properly? In other words, Is System.Web.Mvc.ViewResult.FindView method directly bound to DisplayModes?
- Is DispalyModes feature now part of System.Web.WebPages?
I tried to make sense from the latest source code but couldn't get it right for sure. Also, that would be great if you can point out a good resource (blog post, MSDN article, etc.) (if there is one of course) which explains the latest DisplayModes behaviors.