简体   繁体   English

ASP.net Web窗体和Asp.net MVC安全

[英]ASP.net Web Forms and Asp.net MVC Security

First of all I know this is a very popular topic nowadays, and this question is asked many and many times. 首先,我知道这是当今非常受欢迎的话题,这个问题被问了很多遍了。

But here I'm not asking which is better, since it's very clear that asp.net MVC is better than web forms. 但是在这里我不问哪个更好,因为很明显,asp.net MVC比Web表单更好。

The question here is, what to do with our already written asp.net web form it's neither small nor big, we can call it of medium size. 这里的问题是,如何处理我们已经编写的asp.net Web表单,它既不小也不大,我们可以称其为中等大小。

Is it really deserve to completely rewrite such application with asp.net MVC? 使用asp.net MVC完全重写此类应用程序真的值得吗? The main thing we are concentrating on is Security. 我们主要关注的是安全性。

So if MVC is better than web forms in terms of Performance a little bit only, it would'nt be a big matter. 因此,如果MVC仅在性能方面比Web窗体好一点,那将不是什么大问题。 But if it is better than web forms in terms of security, even a little bit, it's really very important for us. 但是,就安全性而言,如果它比Web表单好一点,那对我们来说真的很重要。

So that's what I want to know: what are the security advantages of wasting a lot of time and money to rewrite an already written web forms application with MVC? 这就是我想知道的:浪费大量时间和金钱用MVC重写已经编写的Web窗体应用程序的安全优势是什么?

Wasting "a lot of time and money" on rewriting well-done web forms code in MVC makes no sense whatsoever. 在MVC中重写做得很好的Web窗体代码浪费“大量的时间和金钱”毫无道理。 To rewrite any code, you need a compelling reason. 要重写任何代码,您需要一个令人信服的理由。

Who said that MVC was "clearly better than web forms"? 谁说MVC“明显优于Web表单”? It is neither better in performance nor in security. 它的性能和安全性都没有。 What it's better in thought, is design. 思想上最好的是设计。

MVC's design encourages the developers to leave the business logic out of the presentation. MVC的设计鼓励开发人员将业务逻辑排除在演示之外。 Although you can also move the logic out of the presentation in web forms too, its design does not encourage that because it takes much more efforts. 尽管您也可以将逻辑从Web表单中移出演示文稿,但是其设计并不鼓励这样做,因为它需要付出更多的努力。 The other way is also true, some developers still add logic to the view in MVC which defeats the purpose. 另一种方法也是正确的,有些开发人员仍然在MVC中向视图添加逻辑,这违背了目的。 Another issue is that MVC does nothing to also encourage the separation of business and data layer leaving that entirely up to the developers, so some developers keep all the logic in the controllers. 另一个问题是,MVC并没有采取任何措施来鼓励业务层和数据层的分离,而是完全由开发人员来决定,因此某些开发人员将所有逻辑保留在控制器中。

The separation of logic from the presentation makes the code much easier to test and much easier to divide between the UI designers and app developers. 逻辑与表示的分离使代码更易于测试,并且更易于在UI设计人员和应用程序开发人员之间进行区分。

All of that is very important to most projects, but not enough reason to rewrite code that's doing its job with no major issues. 所有这些对于大多数项目来说都非常重要,但是没有足够的理由来重写没有大问题的代码。 For new projects, it's definitely worth the consideration. 对于新项目,绝对值得考虑。

There are some other advantages to MVC, but in my opinion the above two are the most important. MVC还有其他一些优点,但是我认为以上两个是最重要的。 Also there are some advantages to web forms and they can be faster to develop certain app with, so we cannot say that MVC is absolutely better than web forms, although the advantages of MVC outweigh the advantages of web forms for most projects (not all), in my opinion. Web表单也有一些优点,并且可以更快地开发某些应用程序,因此我们不能说MVC绝对比Web表单好,尽管MVC的优点对于大多数项目(不是全部)而言都超过了Web窗体的优点。 , 在我看来。

if we leave the many advantages that MVC have over the web forms and the the control that you have over the application and talk about the Business part. 如果我们保留了MVC在Web表单上所拥有的许多优势以及在应用程序上所拥有的控件,并谈论了业务部分。 The question should be changed to these two: 该问题应更改为以下两个:

  1. Do you want an future proof application which is using much more stable framework over which the developers can have full control? 您是否想要一个使用更稳定的框架,供开发人员完全控制的未来应用程序?
  2. Do you want this application just to run till it can? 您是否要一直运行该应用程序?

if your application is going to evolve and will have new versions, functionalities and etc. Then yes you should However if you have static application that will not have big changes ( maybe some minor upgrades and bug fixes) then the investment is not worthy. 如果您的应用程序将要发展并具有新的版本,功能等,那么可以。但是,如果您的静态应用程序没有大的变化(也许会进行一些小的升级和错误修复),那么这笔投资是不值得的。

the security is not the question because the same security can be achieved by both technologies. 安全性不是问题,因为两种技术都可以实现相同的安全性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM