Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible to keep my existing .master page and have it used with a new ASP.NET MVC 3 Razor view? I tried this:

@{
   LayoutPage = "~/Views/Shared/Site.master";
 }

And it gives me this error message:

The file '~/Views/Shared/Site.master' could not be rendered, because it does not exist or is not a valid page.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
587 views
Welcome To Ask or Share your Answers For Others

1 Answer

Unfortunately no. Master pages are a part of the ASPX WebForms view engine, not the MVC framework so Razor cannot interoperate with it.

One option would be to duplicate the masters, as you mentioned, but rather than copying all the code, you could factor the Master page into a bunch of ASPX partials that the Razor and ASPX masters could embed. Then you can start converting each page and partial, one-by-one, to Razor and eventually get rid of the ASPX master.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...