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

后端 未结 2 1335
旧时难觅i
旧时难觅i 2021-02-16 00:24

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:45

    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

提交回复
热议问题