什么是ASP.Net MVC? [英] What Is ASP.Net MVC?

查看:120
本文介绍了什么是ASP.Net MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次听到计算器了,听说它被建在ASP.Net MVC,我有点糊涂了。我以为ASP.Net总是一个MVC架构的一个例子。您可以在.aspx页面提供的观点,.aspx.vb网页,提供控制器,你可以创建另一个类是模型。在ASP.Net MVC使用的过程在这个 Microsoft文章介绍

When I first heard about StackOverflow, and heard that it was being built in ASP.Net MVC, I was a little confused. I thought ASP.Net was always an example of an MVC architecture. You have the .aspx page that provides the view, the .aspx.vb page that provides the controller, and you can create another class to be the model. The process for using MVC in ASP.Net is described in this Microsoft article.

所以我的问题是。什么是ASP.Net MVC提供您将无法与常规ASP.Net(甚至早在ASP.Net 1.1)做?这只是看中网址吗?难道仅仅是为MS吹牛的权利,以便能够适应新的技术,如Ruby on Rails的比较,并说,我们可以做到这一点?有什么更多的ASP.Net MVC实际上提供,而不是在文件 - 一对额外的模板> New菜单?

So my question is. What Does ASP.Net MVC provide that you wouldn't be able to do with regular ASP.Net (even as far back as ASP.Net 1.1)? It is just fancy URLs? Is it just for bragging rights for MS to be able to compare themselves with new technologies like Ruby On Rails, and say, "We can do that too"? Is there something more that ASP.Net MVC actually provides, rather than a couple extra templates in the File->New menu?

我可能真的听起来怀疑和消极的现在,所以我就停止。但我真的想知道ASP.Net MVC实际上提供。另外,如果有人能告诉我,为什么它的模型 - 视图 - 控制器而不是取决于你是否会从上到下,反之亦然视图 - 控制器 - 模型或模型的控制 - 视图层的顺序,我会真的AP preciate这一点。

I'm probably sounding really skeptical and negative right now, so I'll just stop. But I really want to know what ASP.Net MVC actually provides. Also, if anybody can tell me why it's Model-View-Controller and not in order of the layers of View-Controller-Model or Model-Control-View depending on whether you are going top to bottom, or vice versa, I'd really appreciate that too.

修改

此外,它可能是值得指出的是,我从来没有真正关心Web窗体(AKA服务器控件)模型无论是。我只用它最低限度,从不在工作。

Also, it's probably worth pointing out that I've never really cared for the web forms (AKA server controls) model either. I've only used it minimally, and never on the job.

推荐答案

由于的.aspx aspx页面(视图)背后(即'控制'的code调用之前不履行MVC模式)。

.aspx doesn't fulfill the MVC pattern because the aspx page (the 'view') is called before the code behind (the 'controller').

这意味着控制器对来看,这是对MVC的原则很硬依赖关系'。

This means that the controller has a 'hard dependency' on the view, which is very much against MVC principles.

一个MVC的核心优势在于,它可以让你不用实例化一个实景测试控制器(其中含有大量的逻辑)。你根本无法在.aspx世界做到这一点。

One of the core benefits of MVC is that it allows you to test your controller (which contains a lot of logic) without instantiating a real view. You simply can't do this in the .aspx world.

所有的本身测试控制器不必实例化一个完整的asp.net管道(应用程序,请求,响应视图状态,会话状态等)要快得多。

Testing the controller all by itself is much faster than having to instantiate an entire asp.net pipeline (application, request, response, view state, session state etc).

这篇关于什么是ASP.Net MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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