Asp.net MVC 3: Possible to just use the V part?
The title basically describes the question. I have found that the only part of Asp.net that gives me tr开发者_Python百科ouble is the View (Webforms). Is there a way to make use of only the View provided by MVC 3 without implementing the other parts of the technology?
It sounds like you want to use ASP.NET WebPages. This is a new technology built on the Razor viewengine and uses the WebMatrix IDE to help you to build them. You build these apps similar to old classic ASP, but using Razor and C# or VB.NET instead.
You can find more information at The ASP.NET Website, and click on the webpages link, or you can just use the web platform insaller to install webmatrix and start going.
Scott Guthrie writes in his blog post Introducing "Razor" – a new view engine for ASP.NET:
You can also drop standalone .cshtml/.vbhtml files into your application and run them as single-pages – which also enables you to take advantage of it within ASP.NET Web Forms applications as well.
This blog post shows how you can unit test the views part of MVC 3. So you can create a project and build Razor views without using the other parts of MVC.
Yes, it is possible just to use the V part though I dont know why you would not want to use the full M-V-C. The best way to learn the V part is to learn Razor and the best way to do that is with WebMatrix. And here is a great, brief book on Programming Razor.
There is a learning curve with MVC but for me, the productivity gains over web forms made it well worth it. I will never go back to the straight jacket that is the ASP.NET page cycle. The key to learning the MVC architecture is to understand model binding. When model binding clicks for you, you will never look back.
精彩评论