I want to create simple Web Pages 2 applications.
I want to use the File->New->Project->Empty Web Application
and not the File->New-Web Site
.
After i create a new empty web application i cant add a .cshtml file..
The only way that i could do it is:
I am NOT putting the .cshtml file in Views directory. Instead i leave it in root and name it Default.cshtml
Is THIS really the way to do it?
Web Pages 2应用程序是Web 站点 ,而不是Web Applications ,因此您应该执行以下操作:
File » New Web Site » ASP.NET Web Site (Razor 2)
Actually, you can do this. I've done it this way.
Open VS 2013
From the main menu: File > New > Project
Under Installed Templates
Select Templates Visual C# (or VB) Web (do not select VS 2012)
Select ASP.NET Web Application from the list of projects on the right of screen
Next Screen - Select Empty Project, Check Webforms
Run once, get error for no default page
Only files in project Global.asax Web.config
Select "Project" in Solution Explorer (do not select the Solution) Select Manage NuGet Packages
Microsoft ASP.NET Web Pages
Microsoft ASP.NET Web Pages Data (Important! Includes WebMatrix dlls)
Add Layout and View pages Notice the code is recognized as an error
If you run, you get a Server Error that ViewBag does not exist Change ViewBag to Page
Run again. You should be able to develop like standard web pages but with Razor and no viewstate.
That should be it. I've been doing this since VS 2012 and love the results. I contacted Scott H. at MS about adding this as a project type. Didn't get far. He didn't see the point in doing a project this way. IMHO, I disagree.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.