Can we use Razor on an existing ASP.NET 4 website?

后端 未结 3 1291
生来不讨喜
生来不讨喜 2021-01-02 03:47

Is it possible to use Razor on an existing ASP.NET 4 website?

3条回答
  •  有刺的猬
    2021-01-02 04:03

    You shouldn't even need to open the site in Web Matrix if you already have VS2010 and MVC 3 (which includes the Visual Studio tools for building ASP.NET Razor websites) installed. Installing MVC 3 makes the libraries required for developing Razor pages available, even to existing web applications.

    See:

    http://www.asp.net/webmatrix/tutorials/program-asp-net-web-pages-in-visual-studio

    You don't need to create a new Web Pages site (as per the instructions). You can just open up an existing web site, right click the site's root folder, click add item and you should see "Web Page (Razor)" as an option.

    Inellisense and debugging works in the Razor pages just like the Web Forms pages

    As stated above, keep in mind that ASP.Net Web Pages (Razor) and ASP.Net WebForms are really different platforms, and the reusable components of each can not (or at least should not) be used

提交回复
热议问题