I have an MVC view page that uses a master page. The master page is not specified at the top of the view, but is specified in the Controller using the following method on the Controller class:
ViewResult View(string viewName, string masterName, object model)
This runs fine, but Visual Studio 2008 gives a warning in the aspx page: “Unrecognized tag prefix or device filter ‘asp'”.
If I add the MasterPageFile property to the view then the warning goes away. I can’t leave the master page specified here as it can be changed dynamically.
Not a big issue, just slightly annoying.
Perhaps it is complaining about the
<asp:Content>element in your view. Without a statically defined master page, this element is orphaned as far as Visual Studio is able to tell.I don’t think there is any harm to defining the master page within your view and then redefining it programmatically as you have in your action method.