Unrecognized tag prefix or device filter "asp" - MVC ViewPage with master page specified in controller

I have an MVC view page that uses a master page. The main page is not listed at the top of the view, but is listed in the controller using the following Controller class:

ViewResult View(string viewName, string masterName, object model)

      

This works great, but Visual Studio 2008 gives a warning on the aspx page: "Unrecognized tag prefix or device filter" asp ".

If I add the MasterPageFile property to the view, the warning goes away. I cannot leave the master page listed here as it can be dynamically changed.

Not a big problem, just a little annoying.

+2


source to share


2 answers


It might be complaining about an element <asp:Content>

in your view. Without a statically set master page, this element is orphaned as much as Visual Studio can do.



I don't think there is any harm in defining the master page in your view and then overriding it programmatically, like in your action method.

+1


source


I change masters dynamically all the time - you can leave this property there and it will be replaced accordingly. Just pick the default main file and start the person with it.



Now, if you still get the error, make sure you haven't forgotten runat="server"

in the tag asp:Content

. Yes, I lost an hour of my life on this ...

0


source







All Articles