另一个是ASP。NET MVC适合我吗?”的问题

时间:2021-09-06 04:07:23

Here's my particular situation...

这是我的特殊情况下……

I have a decent amount of experience with webforms, and I must say, a lot of it has been pretty frustrating. I like that there are lots of built-in controls, but then I discover that they don't quite do what I want, out of the box. I end up rolling my own controls (that inherit from the built-in controls), such as GridViewThatCanSortItself or GridViewThatHasASelectionColumn (these may not have been the actual names, but you get the idea). I've often wondered, while struggling mightily to build such classes, whether figuring out the often convoluted event model was worth it. My attempts to use css to style things have been frustrating as well. There are some ASP.NET controls that will result in one html tag for one set of attributes and a different tag with another set of attributes. You don't realize this until you notice your css only works half the time.

我对webforms有相当丰富的经验,我必须说,很多都让人很沮丧。我喜欢有很多内置控件,但后来我发现它们并不是我想要的,开箱即用。我最终会滚动自己的控件(从内置控件继承),比如GridViewThatCanSortItself或gridviewthathaselectioncolumn(这些可能不是实际的名称,但您可以理解)。我常常在想,在努力构建这样的类时,是否要计算出复杂的事件模型是值得的。我尝试使用css来设计样式的尝试也很令人沮丧。有一些ASP。NET控件,它将为一组属性生成一个html标记,为另一组属性生成一个不同的标记。直到你注意到你的css只工作了一半时间,你才意识到这一点。

So, my brain starts to wonder, could ASP.NET MVC be the answer? Reading some of the posts on SO has basically given me the impression that, while webforms definitely has its issues, I'd only be trading one set of problems for another. It even seems like Microsoft is trying to talk me out of it:

所以,我的大脑开始思考,ASP。NET MVC是答案吗?读了一些SO上的帖子,我基本上觉得,虽然webforms肯定有自己的问题,但我只会用一套问题来交换另一套问题。看起来微软甚至试图说服我放弃它:

Quote from the asp.net site (http://www.asp.net/learn/mvc/tutorial-01-cs.aspx)

从asp.net站点引用(http://www.asp.net/learn/mvc/tutorial-01-cs.aspx)

ASP.NET MVC...works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior.

ASP。净MVC……对于需要对应用程序行为进行高度控制的大型开发人员和Web设计人员团队支持的Web应用程序,这种方法非常有效。

That is really not me. Most of my projects are relatively small, and I'm usually the only programmer. I sometimes need to create very custom or unusual UI's, but I definitely don't have a team of programmers who can build components for me.

那真的不是我。我的大多数项目都比较小,而且我通常是唯一的程序员。我有时需要创建非常自定义的或不同寻常的UI,但我肯定没有一个程序员团队可以为我构建组件。

There is also the issue of javascript. I have a definite working knowledge of html and css, but I can't say the same for javascript. As clumsy and bloated as they are, I've been able to do some smooth enough looking things with UpdatePanels. I'm not sure how much time I'd need to spend just learning the javascript to be able to handle even simple AJAX scenarios in ASP.NET MVC.

还有javascript的问题。我对html和css有一定的工作知识,但我不能说javascript也是如此。尽管它们笨拙而臃肿,但我已经能够用UpdatePanels做一些看上去足够光滑的事情。我不确定我需要花多少时间去学习javascript才能在ASP中处理简单的AJAX场景。净MVC。

I'm about to start working on a relatively simple and small web app, so now would be the time to take the plunge if I'm going to take the plunge. This app will use a SQL Server Express (2005 or 2008) back-end, and I'm thinking of also trying out SqlMetal as an ORM solution. So, that's already one thing I'm going to have to learn, although I at least have experience with--and really like--LinqToXml and LinqToObject. The pages of the web app will have some data grids (some with link columns), input boxes, labels, drop-down lists, check boxes, radio buttons, and submit/action buttons. I don't foresee anything more complicated than that. There will be about six or seven pages total.

我即将开始开发一个相对简单的、小型的web应用程序,所以如果我打算尝试一下,现在是时候尝试一下了。这个应用程序将使用SQL Server Express(2005或2008)后端,我还在考虑尝试将SqlMetal作为ORM解决方案。所以,这已经是我必须要学习的一件事了,尽管我至少有经验——而且非常喜欢——LinqToXml和LinqToObject。web应用程序的页面将包含一些数据网格(有些带有链接列)、输入框、标签、下拉列表、复选框、单选按钮和提交/操作按钮。我认为没有比这更复杂的了。总共大概有六七页。

Questions:

问题:

Given my experience, how painful will it be to learn ASP.NET MVC? Will it be worth it?

根据我的经验,学习ASP会有多痛苦。净MVC吗?值得吗?

I've read some earlier questions comparing webforms to MVC, so I'm curious, How has MVC evolved over the past year or so? Is there anything new that would make the learning curve less steep?

我之前读过一些比较webforms和MVC的问题,所以我很好奇在过去的一年里MVC是如何发展的?有没有什么新东西可以让学习曲线变得不那么陡峭?

Do I literally have to write code to generate all html by hand or are there code/libraries readily available in the community to assist with the process? (I know I read something about "html helpers"--that may be what I'm asking about here.)

我是否真的必须编写代码来手工生成所有html,或者社区中是否有现成的代码/库来帮助生成过程?(我知道我读过一些关于“html助手”的文章——这可能就是我在这里问的问题。)

Any other advice?

还有其他的建议吗?

Update

更新

Another question that occurred to me: Is the transition from ASP.NET webforms to MVC anything like going from standard WPF (using code-behind) to MVVM? I found learning WPF itself to be pretty challenging (and I still couldn't say I really get everything about it), but learning to work with WPF using the MVVM pattern was a relatively painless transition. So, I'm wondering how similar a jump it is to go from webforms to ASP.NET MVC.

我想到的另一个问题是:ASP的转变。NET webforms到MVC从标准的WPF(代码隐藏)到MVVM?我发现学习WPF本身是很有挑战性的(我仍然不能说我真的得到了所有的东西),但是使用MVVM模式学习使用WPF是一个相对轻松的过渡。所以,我想知道从webforms跳到ASP有多相似。净MVC。

7 个解决方案

#1


6  

My advice is to work through the Nerd Dinner Tutorial from the first chapter of Professional ASP.NET MVC (and then buy the whole book, it's great) to get a feel for how it fits together and how it works for you. This covers most of what you are concerned about above.

我的建议是阅读专业ASP的第一章中的Nerd Dinner Tutorial。NET MVC(然后购买整本书,非常棒)可以了解它是如何组合在一起的,以及它是如何为您工作的。这涵盖了您所关心的大部分内容。

You will have to get your hands dirty with regards working with raw HTML but this is no way near as terrifying as it may sound. Especially as you're having issues where Web Forms takes control.

在使用原始的HTML时,你必须弄脏自己的双手,但这远没有听起来那么可怕。特别是当您遇到Web表单控制的问题时。

#2


3  

Yes, Asp.Net Mvc might be a solution for your problems.

是的,Asp。Net Mvc可能是您的问题的解决方案。

I would highly recommend you not to rush
(without better knowledge you will end up at disappointment).

我强烈建议你不要匆忙(如果没有更好的知识,你最终会失望的)。

But in either way - it definitely be worth it. You will learn a lot.

但无论如何,这绝对是值得的。你会学到很多。

Start with bunch of sample applications while reading some books (start with Sanderson`s, continue with Mvc In Action). Familiarize yourself with asp.net mvc. It demands different way of thinking about web development you are likely used to. And don't be afraid of 3rd party tools - get used to them because asp.net mvc does not focus on 'ready 2 drop through designer and use' solutions and lack of super cool and shiny (with awful js/html underneath) controls at start really frightens.

在阅读一些书籍时,从一些示例应用程序开始(从桑德森的开始,继续使用Mvc)。熟悉asp.net mvc。它要求您以不同的方式考虑您可能习惯的web开发。不要害怕第三方工具——要习惯它们,因为asp.net mvc一开始并不关注“ready 2 drop through designer”,而是使用“解决方案”,而且缺乏超级酷炫的控件(下面有糟糕的js/html)。

After few weeks of playing around with it - you will actually be able to answer this question yourself.
And that's the one and only answer that's worth something.

经过几周的练习,你就可以自己回答这个问题了。这是唯一有价值的答案。


Personally - i prefer asp.net mvc framework and don't want to go back despite that in some cases it does take more work (i.e. - implementation of custom pagination (which can be easily made way more sophisticated than one that pagination control provides)).

就我个人而言,我更喜欢asp.net mvc框架,尽管在某些情况下,它确实需要更多的工作(例如,实现自定义分页(可以很容易地使其比分页控件提供的更复杂)。

Framework demands better knowledge of OOP, architecture and design knowledge, good sense of code tidiness because there is much less 'signs' that provide direction of one and correct way of doing things - they must be figured out in most cases by yourself. So - it is easier to drown in your own sh*t, html tag soup etc. if you are unsure and/or don't know what you are doing.

框架需要更好的OOP知识、架构和设计知识、良好的代码整洁感,因为提供一个方向和正确做事方式的“符号”要少得多——在大多数情况下,它们必须由您自己解决。所以,如果你不确定或者不知道自己在做什么,那么你就更容易被自己的垃圾邮件、html标签汤淹没。


I kind a disagree with that statement about large developer team. This is where knowledge about OOP, 'convention over configuration' and extensability of Mvc framework comes into play. As i see it - it's way more easier (this is really really subjective) to write code that's reusable. And with features like templates (in mvc version no2) count of code lines is reduced drastically.

我不同意关于大开发团队的说法。这就是关于OOP、“约定优于配置”和Mvc框架可扩展性的知识发挥作用的地方。正如我所看到的,编写可重用的代码更容易(这真的很主观)。使用模板(在mvc版本no2中)之类的特性,代码行数量将大大减少。


And learn javascript. You are missing a lot. Play around with jQuery if you haven't done that yet (greatly reduces cross-browser compability problems). Firebug plugin for FireFox is a great aid at this (for debugging purposes). AJAX`ifying your mvc website might seem awkward at first (there's a great tips in 'Mvc in action' book about this topic like form hijacking that can be used to achieve so called progressive enchancement with AJAX), but once you get used to JS - it feels superb. One thing to mention - JS is quite sharp tool (if you don't drop what you know about development in .NET environment and don't use it as it's supposed to). It's easy to screw up JS code base in no time.

和学习javascript。如果您还没有这样做的话,那么就使用jQuery(这大大减少了跨浏览器的兼容性问题)。FireFox的Firebug插件是一个非常好的工具(用于调试)。首先,AJAX使你的mvc网站看起来有些别扭(在《行动指南》中有一个关于这个主题的很棒的提示,比如可以用来实现所谓的AJAX的“进步的机会”),但是一旦你习惯了JS,它就会感觉很好。有一件事需要提及——JS是一个非常尖锐的工具(如果你不放弃你在。net环境中所知道的开发知识,并且不按预期使用的话)。在任何时候都很容易搞砸JS代码库。


Another thing - there's a bunch of myths about mvc framework along those who have touched only web forms.

还有一件事——除了那些只接触过web表单的人之外,还有很多关于mvc框架的神话。

It is not hard to work with raw html.
It is not hard to read form values (binding mechanism is excellent and easily customizable/extensible).
I'm sure there are more. Just can't remember at the moment. :)

使用原始html并不难。读取表单值并不困难(绑定机制非常优秀,并且很容易定制/扩展)。我相信还有更多。只是一时想不起来。:)

#3


2  

@DanThMan, I had the same reservations you did when I first took a look at the framework but having worked with it now for some time there is no way, given the choice, that you'd get me back into WebForms.

@DanThMan,当我第一次看这个框架的时候,我和你有同样的保留,但是现在已经用了一段时间,如果有选择的话,你不可能让我重新进入WebForms。

I also write, from time to time, small applications where I am the only developer and I thank God I stuck to the MVC framework and took the time to really learn it.

我也经常写一些小型的应用程序,我是唯一的开发人员,感谢上帝,我坚持使用MVC框架并花时间去真正地学习它。

In my mind it has made programming fun again and I can now maintain sites quickly and easily which is a first.

在我看来,它又让编程变得有趣了,我现在可以快速轻松地维护站点,这是第一步。

For my money this is the way to go but it's a steep learning curve and you need time to get to really understand it. If you have the time I'd say go for it.

对我来说,这是一条路,但这是一条陡峭的学习曲线,你需要时间去真正理解它。如果你有时间,我就说去争取。

#4


2  

There's some good answers here and some good ones in other threads as well. I'll take a stab at a question that hasn't really been addressed yet.

这里有一些很好的答案,其他线程也有一些很好的答案。我将尝试回答一个还没有真正解决的问题。

How has MVC evolved over the past year or so? Is there anything new that would make the learning curve less steep?

在过去的一年里MVC是如何发展的?有没有什么新东西可以让学习曲线变得不那么陡峭?

I made a conscious switch to MVC about 8 months ago and haven't looked back. Version 1 was stable and I began to use it on a couple of sites with the help of a couple of books and the internet of course. Resources were good back then but since I switched things have really blown up in a good way.

8个月前,我有意识地转向了MVC,并没有回头。版本1是稳定的,我开始在一些网站上使用它,在一些书籍和互联网的帮助下。那时的资源很好,但自从我换了工作后,事情就以一种很好的方式爆发了。

There are a couple of books out there for version 1 that are top notch (Steve Sanderson's - Pro ASP.NET MVC Framework and the Nerd Dinner book come to mind). And there is definitely asp.net MVC blood in the water so I imagine there will be some great version 2 books down the line.

有几本关于第一版的书是一流的(Steve Sanderson的- Pro ASP)。我想到了NET MVC框架和Nerd(书呆子)晚餐书)。而且肯定有asp.net MVC的血液在水里,所以我想接下来会有一些很棒的版本2的书。

The developer community, especially here, is excellent and it's getting better. "asp.net-mvc" is currently the 16th most used tag on this site and often has a very high amount of views per question. As of today I have yet to have a question that hasn't been answered. There's a lot of smart people looking at the MVC questions who are willing to help.

开发人员社区,尤其是这里,非常优秀,而且正在变得越来越好。“asp.net-mvc”目前是这个网站上使用最多的第16个标签,每个问题的浏览量通常都非常高。到今天为止,我还没有一个问题没有得到回答。有很多聪明的人在看MVC问题,他们愿意提供帮助。

The contrib library over at codeplex is also getting better and getting some nice participation. They've done a great job of filling in some holes that version 1 has left. I can only think that this will continue to get stronger as MVC gets older.

codeplex上的这个图书馆也在变得更好,并且得到了一些很好的参与。他们在填补版本1留下的漏洞方面做得很好。我只能认为随着MVC变老,它会继续变得更强大。

The new features for version 2 are in my opinion awesome. I won't name my favorites as they won't mean much to you if you haven't played with MVC much but just know that the development team has listened and included a number of great enhancements for the new version. They are very actively seeking feedback and always looking for improvements. Do not expect this change anytime soon. (One day I called up Microsoft and said "Shorten '[AcceptVerb(Http.Post)]' to '[HttpPost]'" and bam, Mvc 2 was my idea.)

在我看来,版本2的新特性非常棒。我不愿说出我最喜欢的名字,因为它们对你来说并不重要,如果你还没有玩过MVC,但只知道开发团队已经听过了,并在新版本中加入了一些很棒的增强功能。他们非常积极地寻求反馈,总是寻求改进。不要指望这种变化会很快发生。(有一天我打电话给微软,说“把‘AcceptVerb(Http.Post)’缩短为‘[HttpPost]’”,bam, Mvc 2就是我的主意。)

The point I'm trying to make is: since I made the switch I've seen things get better and better. I'm incredibly happy with my decision and I'm excited for the future of this project. Version 1 is good, Version 2 is better and I can't wait to see what 3, 4, and 5 ... hold.

我想说的是:自从我做出改变,我看到事情越来越好。我对自己的决定感到非常高兴,我也为这个项目的未来感到兴奋。版本1很好,版本2更好,我迫不及待地想看看3、4和5……持有。

And I'll leave you with this: I've now converted a number of friends from WebForms to MVC. Every single one of the them is glad they made the switch and the ones that work with all aspects of an application (C# code, html, css, javascript, data access, unit testing, etc) will never go back and are loving the asp.net MVC life.

我要告诉你们的是:我现在已经将许多朋友从WebForms转换为MVC。他们中的每一个人都很高兴他们做出了改变,而那些与应用程序的所有方面(c#代码、html、css、javascript、数据访问、单元测试等等)一起工作的人将永远不会回到过去,并热爱asp.net MVC的生活。

#5


1  

Given my experience, how painful will it be to learn ASP.NET MVC? Will it be worth it?

根据我的经验,学习ASP会有多痛苦。净MVC吗?值得吗?

Yes and yes. It will be painful and it will be worth it and here's why. You will be a better programmer for it and your skills will more easily transfer to other platforms. MVC is a very common pattern that you will find over and over again in just about every popular language.

是的,是的。这将是痛苦的,是值得的,原因如下。你将成为一个更好的程序员,你的技能将更容易转移到其他平台。MVC是一种非常常见的模式,您可以在几乎所有流行的语言中反复找到它。

You will be working more closely with html, javascript, and css, but that's web programming and you're better off biting the bullet sooner than later.

您将更密切地使用html、javascript和css,但这是web编程,您最好及早解决问题。

#6


1  

having worked my last few projects (prior to embracing mvc) using my own controls being rolled via the HtmlTextWriter, I actually found th transition quite straightfwd. i have to say tho', i did put it off until v1.0 was well and truly 'out there' and only made strides from aug/sept 09. i'm glad i got into it as the main reasons i had been using the HtmlTextWriter in webforms was to overcome some of the basic issues of class names and id's when using jquery. i'm not going to say that v1 is a silver bullet but it certainly just works in tandem with my mindset at the moment. as for literature, i too read the sanserson and nerd dinner books and took plenty away from them. at the same time, i also got into subsonic v3 and found a fair amount of tips on rob's site to get me going.

在使用我自己的通过HtmlTextWriter滚动的控件完成我最后的几个项目(在使用mvc之前)之后,我发现这个转换非常简单。我不得不说,我确实把它推迟了,直到v1.0运行良好,真正的“在那里”,从09年8月到9月9日才有了长足的进步。我很高兴我加入了它,因为我在webforms中使用HtmlTextWriter的主要原因是在使用jquery时克服了类名和id的一些基本问题。我不会说v1是一颗银弹,但它确实与我目前的思维方式是一致的。至于文学,我也读过sanserson和nerd的晚餐书,从里面拿走了很多。与此同时,我也进入了亚音速v3,在rob的网站上找到了相当多的提示让我继续前进。

i seriously can't imagine having to go 'back' to the webforms paradigm as i had been looking for a way to drop the page lifecycle and controls bloat for such a long time (i had even looked at php framewirks at one point as a way out of the webforms dilema - kohana is a great little php framework).

我真的不能想象在“回”到webforms范式,我一直在寻找一种将页面生命周期和控制膨胀这么长时间(我甚至看着php framewirks一度的出路webforms dilema - kohana是一个很棒的小php框架)。

anyway, just my scottish 2 pence worth...

不管怎样,我的苏格兰2便士……

merry xmas all and a happy 2010

圣诞快乐,2010年快乐

jimi

吉米

#7


1  

Some developers seem to have an aversion to component-oriented programming. For others, it feels natural. If you find yourself constantly fighting the standard components, then it's easy enough to roll your own from scratch--which you would basically end up doing in MVC anyway. If you find yourself fighting the unit test model with web forms, you will find things easier with MVC.

有些开发人员似乎讨厌面向组件的编程。对其他人来说,这感觉很自然。如果您发现自己一直在与标准组件作斗争,那么从头开始就足够容易了——无论如何,您最终都会在MVC中这样做。如果您发现自己正在用web表单与单元测试模型进行斗争,那么您将发现使用MVC更容易实现。

However, MVC isn't a cure-all; there's a lot to learn. Some apps will be less complex than with web forms, and some will be much more complex.

然而,MVC并不是万能的;有很多东西需要学习。有些应用程序比web表单要简单,有些则要复杂得多。

I've found that web forms don't really gel with many developers until they deeply understand the page life cycle and use of ViewState. Until that point, there seems to be a lot of trial and error -- but it's easier to learn that than MVC with IOC, etc. As far as customizing output, it's often easier to use control adapters than to subclass the control. In case it helps, I walk through these issues from the web forms side in my book: Ultra-Fast ASP.NET.

我发现,在许多开发人员深入理解页面生命周期和ViewState的使用之前,web表单并不能真正与他们融合。在此之前,似乎有很多尝试和错误——但是要了解这一点比使用IOC等MVC容易得多。就定制输出而言,使用控制适配器通常比子类化控件容易得多。如果有帮助的话,我在我的书中从web表单的一面来介绍这些问题:超高速ASP.NET。

In the end, I think it's partly a mindset thing, and which model fits the way you solve problems and think about your application better.

最后,我认为这在一定程度上是一种思维方式,哪种模型适合您解决问题和更好地考虑应用程序的方式。

#1


6  

My advice is to work through the Nerd Dinner Tutorial from the first chapter of Professional ASP.NET MVC (and then buy the whole book, it's great) to get a feel for how it fits together and how it works for you. This covers most of what you are concerned about above.

我的建议是阅读专业ASP的第一章中的Nerd Dinner Tutorial。NET MVC(然后购买整本书,非常棒)可以了解它是如何组合在一起的,以及它是如何为您工作的。这涵盖了您所关心的大部分内容。

You will have to get your hands dirty with regards working with raw HTML but this is no way near as terrifying as it may sound. Especially as you're having issues where Web Forms takes control.

在使用原始的HTML时,你必须弄脏自己的双手,但这远没有听起来那么可怕。特别是当您遇到Web表单控制的问题时。

#2


3  

Yes, Asp.Net Mvc might be a solution for your problems.

是的,Asp。Net Mvc可能是您的问题的解决方案。

I would highly recommend you not to rush
(without better knowledge you will end up at disappointment).

我强烈建议你不要匆忙(如果没有更好的知识,你最终会失望的)。

But in either way - it definitely be worth it. You will learn a lot.

但无论如何,这绝对是值得的。你会学到很多。

Start with bunch of sample applications while reading some books (start with Sanderson`s, continue with Mvc In Action). Familiarize yourself with asp.net mvc. It demands different way of thinking about web development you are likely used to. And don't be afraid of 3rd party tools - get used to them because asp.net mvc does not focus on 'ready 2 drop through designer and use' solutions and lack of super cool and shiny (with awful js/html underneath) controls at start really frightens.

在阅读一些书籍时,从一些示例应用程序开始(从桑德森的开始,继续使用Mvc)。熟悉asp.net mvc。它要求您以不同的方式考虑您可能习惯的web开发。不要害怕第三方工具——要习惯它们,因为asp.net mvc一开始并不关注“ready 2 drop through designer”,而是使用“解决方案”,而且缺乏超级酷炫的控件(下面有糟糕的js/html)。

After few weeks of playing around with it - you will actually be able to answer this question yourself.
And that's the one and only answer that's worth something.

经过几周的练习,你就可以自己回答这个问题了。这是唯一有价值的答案。


Personally - i prefer asp.net mvc framework and don't want to go back despite that in some cases it does take more work (i.e. - implementation of custom pagination (which can be easily made way more sophisticated than one that pagination control provides)).

就我个人而言,我更喜欢asp.net mvc框架,尽管在某些情况下,它确实需要更多的工作(例如,实现自定义分页(可以很容易地使其比分页控件提供的更复杂)。

Framework demands better knowledge of OOP, architecture and design knowledge, good sense of code tidiness because there is much less 'signs' that provide direction of one and correct way of doing things - they must be figured out in most cases by yourself. So - it is easier to drown in your own sh*t, html tag soup etc. if you are unsure and/or don't know what you are doing.

框架需要更好的OOP知识、架构和设计知识、良好的代码整洁感,因为提供一个方向和正确做事方式的“符号”要少得多——在大多数情况下,它们必须由您自己解决。所以,如果你不确定或者不知道自己在做什么,那么你就更容易被自己的垃圾邮件、html标签汤淹没。


I kind a disagree with that statement about large developer team. This is where knowledge about OOP, 'convention over configuration' and extensability of Mvc framework comes into play. As i see it - it's way more easier (this is really really subjective) to write code that's reusable. And with features like templates (in mvc version no2) count of code lines is reduced drastically.

我不同意关于大开发团队的说法。这就是关于OOP、“约定优于配置”和Mvc框架可扩展性的知识发挥作用的地方。正如我所看到的,编写可重用的代码更容易(这真的很主观)。使用模板(在mvc版本no2中)之类的特性,代码行数量将大大减少。


And learn javascript. You are missing a lot. Play around with jQuery if you haven't done that yet (greatly reduces cross-browser compability problems). Firebug plugin for FireFox is a great aid at this (for debugging purposes). AJAX`ifying your mvc website might seem awkward at first (there's a great tips in 'Mvc in action' book about this topic like form hijacking that can be used to achieve so called progressive enchancement with AJAX), but once you get used to JS - it feels superb. One thing to mention - JS is quite sharp tool (if you don't drop what you know about development in .NET environment and don't use it as it's supposed to). It's easy to screw up JS code base in no time.

和学习javascript。如果您还没有这样做的话,那么就使用jQuery(这大大减少了跨浏览器的兼容性问题)。FireFox的Firebug插件是一个非常好的工具(用于调试)。首先,AJAX使你的mvc网站看起来有些别扭(在《行动指南》中有一个关于这个主题的很棒的提示,比如可以用来实现所谓的AJAX的“进步的机会”),但是一旦你习惯了JS,它就会感觉很好。有一件事需要提及——JS是一个非常尖锐的工具(如果你不放弃你在。net环境中所知道的开发知识,并且不按预期使用的话)。在任何时候都很容易搞砸JS代码库。


Another thing - there's a bunch of myths about mvc framework along those who have touched only web forms.

还有一件事——除了那些只接触过web表单的人之外,还有很多关于mvc框架的神话。

It is not hard to work with raw html.
It is not hard to read form values (binding mechanism is excellent and easily customizable/extensible).
I'm sure there are more. Just can't remember at the moment. :)

使用原始html并不难。读取表单值并不困难(绑定机制非常优秀,并且很容易定制/扩展)。我相信还有更多。只是一时想不起来。:)

#3


2  

@DanThMan, I had the same reservations you did when I first took a look at the framework but having worked with it now for some time there is no way, given the choice, that you'd get me back into WebForms.

@DanThMan,当我第一次看这个框架的时候,我和你有同样的保留,但是现在已经用了一段时间,如果有选择的话,你不可能让我重新进入WebForms。

I also write, from time to time, small applications where I am the only developer and I thank God I stuck to the MVC framework and took the time to really learn it.

我也经常写一些小型的应用程序,我是唯一的开发人员,感谢上帝,我坚持使用MVC框架并花时间去真正地学习它。

In my mind it has made programming fun again and I can now maintain sites quickly and easily which is a first.

在我看来,它又让编程变得有趣了,我现在可以快速轻松地维护站点,这是第一步。

For my money this is the way to go but it's a steep learning curve and you need time to get to really understand it. If you have the time I'd say go for it.

对我来说,这是一条路,但这是一条陡峭的学习曲线,你需要时间去真正理解它。如果你有时间,我就说去争取。

#4


2  

There's some good answers here and some good ones in other threads as well. I'll take a stab at a question that hasn't really been addressed yet.

这里有一些很好的答案,其他线程也有一些很好的答案。我将尝试回答一个还没有真正解决的问题。

How has MVC evolved over the past year or so? Is there anything new that would make the learning curve less steep?

在过去的一年里MVC是如何发展的?有没有什么新东西可以让学习曲线变得不那么陡峭?

I made a conscious switch to MVC about 8 months ago and haven't looked back. Version 1 was stable and I began to use it on a couple of sites with the help of a couple of books and the internet of course. Resources were good back then but since I switched things have really blown up in a good way.

8个月前,我有意识地转向了MVC,并没有回头。版本1是稳定的,我开始在一些网站上使用它,在一些书籍和互联网的帮助下。那时的资源很好,但自从我换了工作后,事情就以一种很好的方式爆发了。

There are a couple of books out there for version 1 that are top notch (Steve Sanderson's - Pro ASP.NET MVC Framework and the Nerd Dinner book come to mind). And there is definitely asp.net MVC blood in the water so I imagine there will be some great version 2 books down the line.

有几本关于第一版的书是一流的(Steve Sanderson的- Pro ASP)。我想到了NET MVC框架和Nerd(书呆子)晚餐书)。而且肯定有asp.net MVC的血液在水里,所以我想接下来会有一些很棒的版本2的书。

The developer community, especially here, is excellent and it's getting better. "asp.net-mvc" is currently the 16th most used tag on this site and often has a very high amount of views per question. As of today I have yet to have a question that hasn't been answered. There's a lot of smart people looking at the MVC questions who are willing to help.

开发人员社区,尤其是这里,非常优秀,而且正在变得越来越好。“asp.net-mvc”目前是这个网站上使用最多的第16个标签,每个问题的浏览量通常都非常高。到今天为止,我还没有一个问题没有得到回答。有很多聪明的人在看MVC问题,他们愿意提供帮助。

The contrib library over at codeplex is also getting better and getting some nice participation. They've done a great job of filling in some holes that version 1 has left. I can only think that this will continue to get stronger as MVC gets older.

codeplex上的这个图书馆也在变得更好,并且得到了一些很好的参与。他们在填补版本1留下的漏洞方面做得很好。我只能认为随着MVC变老,它会继续变得更强大。

The new features for version 2 are in my opinion awesome. I won't name my favorites as they won't mean much to you if you haven't played with MVC much but just know that the development team has listened and included a number of great enhancements for the new version. They are very actively seeking feedback and always looking for improvements. Do not expect this change anytime soon. (One day I called up Microsoft and said "Shorten '[AcceptVerb(Http.Post)]' to '[HttpPost]'" and bam, Mvc 2 was my idea.)

在我看来,版本2的新特性非常棒。我不愿说出我最喜欢的名字,因为它们对你来说并不重要,如果你还没有玩过MVC,但只知道开发团队已经听过了,并在新版本中加入了一些很棒的增强功能。他们非常积极地寻求反馈,总是寻求改进。不要指望这种变化会很快发生。(有一天我打电话给微软,说“把‘AcceptVerb(Http.Post)’缩短为‘[HttpPost]’”,bam, Mvc 2就是我的主意。)

The point I'm trying to make is: since I made the switch I've seen things get better and better. I'm incredibly happy with my decision and I'm excited for the future of this project. Version 1 is good, Version 2 is better and I can't wait to see what 3, 4, and 5 ... hold.

我想说的是:自从我做出改变,我看到事情越来越好。我对自己的决定感到非常高兴,我也为这个项目的未来感到兴奋。版本1很好,版本2更好,我迫不及待地想看看3、4和5……持有。

And I'll leave you with this: I've now converted a number of friends from WebForms to MVC. Every single one of the them is glad they made the switch and the ones that work with all aspects of an application (C# code, html, css, javascript, data access, unit testing, etc) will never go back and are loving the asp.net MVC life.

我要告诉你们的是:我现在已经将许多朋友从WebForms转换为MVC。他们中的每一个人都很高兴他们做出了改变,而那些与应用程序的所有方面(c#代码、html、css、javascript、数据访问、单元测试等等)一起工作的人将永远不会回到过去,并热爱asp.net MVC的生活。

#5


1  

Given my experience, how painful will it be to learn ASP.NET MVC? Will it be worth it?

根据我的经验,学习ASP会有多痛苦。净MVC吗?值得吗?

Yes and yes. It will be painful and it will be worth it and here's why. You will be a better programmer for it and your skills will more easily transfer to other platforms. MVC is a very common pattern that you will find over and over again in just about every popular language.

是的,是的。这将是痛苦的,是值得的,原因如下。你将成为一个更好的程序员,你的技能将更容易转移到其他平台。MVC是一种非常常见的模式,您可以在几乎所有流行的语言中反复找到它。

You will be working more closely with html, javascript, and css, but that's web programming and you're better off biting the bullet sooner than later.

您将更密切地使用html、javascript和css,但这是web编程,您最好及早解决问题。

#6


1  

having worked my last few projects (prior to embracing mvc) using my own controls being rolled via the HtmlTextWriter, I actually found th transition quite straightfwd. i have to say tho', i did put it off until v1.0 was well and truly 'out there' and only made strides from aug/sept 09. i'm glad i got into it as the main reasons i had been using the HtmlTextWriter in webforms was to overcome some of the basic issues of class names and id's when using jquery. i'm not going to say that v1 is a silver bullet but it certainly just works in tandem with my mindset at the moment. as for literature, i too read the sanserson and nerd dinner books and took plenty away from them. at the same time, i also got into subsonic v3 and found a fair amount of tips on rob's site to get me going.

在使用我自己的通过HtmlTextWriter滚动的控件完成我最后的几个项目(在使用mvc之前)之后,我发现这个转换非常简单。我不得不说,我确实把它推迟了,直到v1.0运行良好,真正的“在那里”,从09年8月到9月9日才有了长足的进步。我很高兴我加入了它,因为我在webforms中使用HtmlTextWriter的主要原因是在使用jquery时克服了类名和id的一些基本问题。我不会说v1是一颗银弹,但它确实与我目前的思维方式是一致的。至于文学,我也读过sanserson和nerd的晚餐书,从里面拿走了很多。与此同时,我也进入了亚音速v3,在rob的网站上找到了相当多的提示让我继续前进。

i seriously can't imagine having to go 'back' to the webforms paradigm as i had been looking for a way to drop the page lifecycle and controls bloat for such a long time (i had even looked at php framewirks at one point as a way out of the webforms dilema - kohana is a great little php framework).

我真的不能想象在“回”到webforms范式,我一直在寻找一种将页面生命周期和控制膨胀这么长时间(我甚至看着php framewirks一度的出路webforms dilema - kohana是一个很棒的小php框架)。

anyway, just my scottish 2 pence worth...

不管怎样,我的苏格兰2便士……

merry xmas all and a happy 2010

圣诞快乐,2010年快乐

jimi

吉米

#7


1  

Some developers seem to have an aversion to component-oriented programming. For others, it feels natural. If you find yourself constantly fighting the standard components, then it's easy enough to roll your own from scratch--which you would basically end up doing in MVC anyway. If you find yourself fighting the unit test model with web forms, you will find things easier with MVC.

有些开发人员似乎讨厌面向组件的编程。对其他人来说,这感觉很自然。如果您发现自己一直在与标准组件作斗争,那么从头开始就足够容易了——无论如何,您最终都会在MVC中这样做。如果您发现自己正在用web表单与单元测试模型进行斗争,那么您将发现使用MVC更容易实现。

However, MVC isn't a cure-all; there's a lot to learn. Some apps will be less complex than with web forms, and some will be much more complex.

然而,MVC并不是万能的;有很多东西需要学习。有些应用程序比web表单要简单,有些则要复杂得多。

I've found that web forms don't really gel with many developers until they deeply understand the page life cycle and use of ViewState. Until that point, there seems to be a lot of trial and error -- but it's easier to learn that than MVC with IOC, etc. As far as customizing output, it's often easier to use control adapters than to subclass the control. In case it helps, I walk through these issues from the web forms side in my book: Ultra-Fast ASP.NET.

我发现,在许多开发人员深入理解页面生命周期和ViewState的使用之前,web表单并不能真正与他们融合。在此之前,似乎有很多尝试和错误——但是要了解这一点比使用IOC等MVC容易得多。就定制输出而言,使用控制适配器通常比子类化控件容易得多。如果有帮助的话,我在我的书中从web表单的一面来介绍这些问题:超高速ASP.NET。

In the end, I think it's partly a mindset thing, and which model fits the way you solve problems and think about your application better.

最后,我认为这在一定程度上是一种思维方式,哪种模型适合您解决问题和更好地考虑应用程序的方式。