为什么MVC,而不是良好的老ASP.NET?还是不抓我为什么要走这条路? [英] Why MVC instead of good old ASP.NET? Still not grasping why I should go this route?

查看:139
本文介绍了为什么MVC,而不是良好的老ASP.NET?还是不抓我为什么要走这条路?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问过,我看所有的答案,但他们还是不给我,我要找的答案。我需要的东西具体化。我主动给的MVC中的presentation给其他开发商在我们的小组迫使我去学习它。最大的问题每个人都有是:我能MVC带来的表,我们不能做的asp.net或MVC能够做到更快我刚才走过的书呆子晚餐,实际上建立了一个完整的网站之类的模拟书呆子晚餐但作为一个伟大的工作,斯科特·格思里做就可以了,但是也有一些并不如回答很大的差距,我怎么扔一个文本框与按钮列表页面上,做一个简单的搜索,在asp.net中,我将引发页面上的文本框,按钮和网格并将其绑定到一个存储过程,并走我走。什么是等值的MVC,我想我需要关于如何使用MVC不使用LINQ到SQL一个很好的教程。

我知道那种我咿咿呀呀的有关这一点,但它是一个似乎仍然置之不理一个非常严肃的问题。

在一个侧面说明,MVC的查看页面带回传统的ASP与我们就脱离了与后面的页面code遥想当年所有的在线code噩梦。是的,MVC具有控制器和模型类,它们是伟大的,但我还是不喜欢传统的ASP代码的HTML。

帮我在这里,我真的很喜欢MVC的概念,并希望它是成功的,但我需要更多!

解决方案
  

我怎么扔一个按钮列表页面上的文本框,并做一个简单的搜索。在asp.net,我就把页面上的文本框,按钮和网格并将其绑定到一个存储过程,并远离我去

这正是背后的经典ASP.NET又名WebForms的最大的问题。

您不应该思考的是页,按钮和活动方面。

您应该学习如何网络工作的基础。然后,你会明白,在网络中讲HTTP协议的条款,它的命令GET,POST等。 presentation是HTML,CSS和文档对象模型这就是JavaScript的用武之地。和有实际上任何页面,一个URL是只是一个指向其本身未必映射到服务器上的物理文件(html的或的.aspx)的一个资源。

  

MVC的查看页面带回传统的ASP与我们就脱离了与后面的页面code遥想当年所有的在线code恶梦。

我也来MVC住在一起的WebForms后,我发现我喜欢的直列code非常多。它使视图结构很清晰,这不能说有关的静态标记(CSS)的联轴器+在code-背后操纵服务器控件。后者实际上是一个噩梦 - 你的code正在生成的标记输出,但是你看不到的地方,以及如何

  

什么MVC带来的表,我们不能做的asp.net或MVC可以做得更快

它移除了的WebForms给我们丑陋的状态抽象。现在,您回到起点。你现在拥有的是:

  • 选项可将presentation部分(视图)从应用程序逻辑中分离出来。之前曾有都混在一起,code-背后谈论到数据库,调用其他服务,修改标记。这是一团糟。这导致了大量的书面重要的应用程序,但几乎没有维护了。

  • 能够自动测试你的应用程序逻辑。随着WebForms和code-的背后,你会怎么调用某个场景?你会使用工具,如硒来模拟用户活动。现在,当你的观点只是一个被动的presentation层,就没有这个问题了。你很容易测试你的业务逻辑和模式输出。视图是没有显示结果。如果模型得到了正确的数据在特定的情况下,视图将正确显示。如果没有,那么没有。期。无需测试的看法。

  • 掌控自己的标记。也就是说,如果你的关心。如果你以前使用Windows开发谁不给有关HTML文档是有效的,是语义正确和Web引擎优化该死的,那么它是没有用的你。我的意思是,网页的排序显示,用户点击在桌面应用程序处理的像,还有什么,对不对?但是,如果你有兴趣在所有这些事情,那么你就看着最后的标记输出,并看到它是丑陋的,有很多错误,你根本无法修复的限制。因为它是如何控制,按钮,数据网格等展示自我。解决这些问题的尝试将需要重写这些控件这是一个任务繁重的标记生成。为什么不只是把它和手工做的一切?

  

什么MVC需要从表中?

的控制,事件,就像在Windows编程中的服务器端处理。如果你正在开发一个类似桌面的应用程序的网络中,像那些典型的企业软件与数十上百控制来驱动你疯了,那么MVC将推动你疯了,因为你将不得不单独连线每个单独的控制JavaScript的。

但是,如果你不开发这些类型的应用程序(需要一定的智力与工作),但发展现代实用软件的网页,然后的WebForms将推动你疯了。迟早的事。

I know this question has been asked before and I read all the answers but they still don't give me the answers I am looking for. I need something concrete. I volunteered to give a presentation on MVC to other developers in our group which forces me to learn it. The big question everyone has is: "What can MVC bring to the table that we can't do in asp.net or MVC can do faster. I have just gone through Nerd Dinner and actually created a complete website that sort of mimics Nerd Dinner. But as great a job that Scott Guthrie did on it, there are big gaps that aren't answered such as, how do I throw a textbox on the listing page with a button and do a simple search. In asp.net, I would throw a textbox, button and grid on the page and bind it to a sproc and away I go. What is the equivalent in MVC. I guess I need a really good tutorial on how to use MVC without using Linq-to-Sql.

I know I am sort of babbling on about this but it is a very serious question that still seems to go unanswered.

On a side note, the View page of MVC brings back nightmares of classic asp with all the in-line code that we got away from way back when with code behind pages. Yes, MVC has Controller and Model classes which are great but I still don't like the classic asp tags in the html.

Help me out here, I really like the concept of MVC and want it to be successful but I need more!

解决方案

how do I throw a textbox on the listing page with a button and do a simple search. In asp.net, I would throw a textbox, button and grid on the page and bind it to a sproc and away I go

That's exactly the biggest problem behind "classic" ASP.NET aka WebForms.

You shouldn't be thinking in terms of pages, buttons and events.

You should learn the basics of how web works. Then you'd understand that the web speaks in terms of HTTP protocol, its commands GET, POST and others. Presentation is HTML, CSS and the Document Object Model which is where JavaScript comes into play. And there are in fact no pages, an url is just a pointer to a resource which is not necessarily mapped to a physical file (.html or .aspx) on the server.

the View page of MVC brings back nightmares of classic asp with all the in-line code that we got away from way back when with code behind pages.

I also came to MVC after staying with WebForms and I discovered I like the inline code very much. It makes the view structure very clear, which cannot be said about the coupling of static markup (aspx) + manipulating server controls in code-behind. The latter is actually a nightmare - your code is generating the markup output but you don't see where and how.

What can MVC bring to the table that we can't do in asp.net or MVC can do faster

It removes the ugly stateful abstraction which WebForms gave us. You're now back where it started. What you have now is:

  • Option to separate your presentation part (views) from your application logic. Before there was all mixed together, code-behind talking to the database, calling other services, modifying the markup. It was mess. It resulted in lots of serious applications written but hardly maintainable any more.

  • Ability to automatically test your application logic. With WebForms and code-behind, how would you invoke a certain scenario? You'd use tools like Selenium to mimic user activities. Now, when your views are just a passive presentation layer, you don't have this problem any more. You test your business logic and model output very easily. Views are there to display the results. If the model got the correct data in a particular scenario, the view will display it correctly. If not then not. Period. No need to test views.

  • Control over your markup. That is if you care. If you a former Windows developer who doesn't give a damn about HTML documents being valid, being semantically correct and optimized for web engines, then it's of no use to you. I mean, "pages" are sort of displayed, user clicks are processed like in desktop application, what else, right? But if you were interested in all those things, then you'd look at the final markup output and see that it is ugly, with lots of errors, limitations which you simply can't fix. Because it's how controls, buttons, data grids etc. display themselves. An attempt to fix them would require to override markup generation of those controls which is a heavy task. Why don't just drop it and do everything manually?

What MVC takes from the table?

A server-side processing of "control" "events", like in Windows programming. If you're developing a desktop-like application for web medium, like those typical "business" software with dozens and hundreds of controls to drive you crazy, then MVC will drive you crazy, because you will have to wire each single control individually with JavaScript.

But if you're not developing those kinds of applications (which require certain mental abilities to work with), but developing modern usable software for web, then WebForms would drive you crazy. Sooner or later.

这篇关于为什么MVC,而不是良好的老ASP.NET?还是不抓我为什么要走这条路?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆