Web forms view engine and razor view engine in the same project

后端 未结 2 1917
Happy的楠姐
Happy的楠姐 2021-02-16 00:36

I work on a product which up to this point has been using the web forms view engine for all its views. There are far too many files to refactor.

Is there any reason why

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-16 00:40

    ASP.NET MVC supports the use of both the Razor and WebForms views in the same project with the default configuration.

    The default View engine will search for a view in this order

    ~/Views/Home/Index.aspx (WebForms)
    ~/Views/Shared/Index.aspx (WebForms)
    ~/Views/Home/Index.cshtml (Razor)
    ~/Views/Shared/Index.cshtml (Razor)
    

    So if you have a WebForms and Razor view of the same name then the WebForms view will be shown.

    Scott Hansleman has more details on mixing WebForms and Razor views in one layout/master page

提交回复
热议问题