There is a project on mvc. And he developed an interface for 2 browsers. Accordingly made 2 master page. _layout for chrome and _layout.old for IE. In _ViewStart code, the standard code for all mvc projects:

@{ Layout = "~/Views/Shared/_Layout.cshtml"; } 

When debugging, I look, it does not matter in which browser I run the project on this line, the code comes in, and then already if it is chrome, then the project jumps to the new interface starting from the authorization page and if in explorer then to the old one. I can not understand where in the project this routing is done, how does the project choose where to look? Please tell me how it is done and where can I see it?

  • Check out _ViewStart.cshtml or search by name layouts - demonplus
  • @demonplus did you read my question carefully? There will lead the code twist start. And by the names of the master of the pages I did everything, I did not find anything in the whole project that they would meet. - Andrei
  • Then this is magic :) - demonplus
  • @demonplus thanks for the help ... - Andrei
  • Well, is the browser somewhere determined? Try searching Request.Browser for all files - demonplus

1 answer 1

Guessing on the coffee grounds, but still ...

The controller has one of the method method View overloads.

protected internal virtual System.Web.Mvc.ViewResult View (string viewName, string masterName, object model);

As can be seen from the signature, we can explicitly specify the necessary master page from the code.