ASP.NET MVC vs. Webforms vs. HTTP Handlers (.ashx) - which is the most lightweight? [closed]

浪尽此生 提交于 2019-12-18 13:35:35

问题


I plan on building a simple, yet high usage webapp and need to settle on an architecture.

  • basic server side logic / dynamic db driven content about half a dozen to a dozen pages serving up all said content
  • no need for URL rewriting,
  • pretty simple page flow/routing

The objective is to publish this app to use the least amount of bandwidth, memory, and CPU as possible. That said, my options are to

  1. build in ASP.NET MVC

  2. build in webforms with viewstate disabled

  3. build using .ashx handlers with code that concatenates all HTML output into strings that it spits out

Which is the most lightweight solution?

I appreciate the responses so far, but i'm not asking for the best solution. This is a simple app, and i want the solution that will use the fewest machine/network resources.


回答1:


HttpHandlers are the most light weight, because the interface behind the ASHX file is IHttpHandler which is the basis of the Page object that is used both for Web Forms and MVC.




回答2:


HttpHandlers are the most lightweight from your list of 3 options.

Personally, I would use ASP.NET MVC because it gives you a richer development environment with very little extra server overhead, especially if u turn most things off ..

eg. roles, etc.

Also use IIS7 intergrated mode and turn as much IIS7 settings off etc.




回答3:


Omit the third option because it is very hard to control the application if it is all built using HttpHandlers.

basic server side logic / dynamic db driven content about half a dozen to

One of the major benefits of ASP.NET MVC is the ease of the separation of concerns. +1

a dozen pages serving up all said content no need for URL rewriting, pretty simple page flow/routing

ASP.NET MVC will give you an easy interface to set your routes, a lightweight,clear, and controllable views. +1




回答4:


WebForms are going to be the heaviest in most cases. ASP.Net MVC is quite lightweight and surprisingly fast compared to WebForms.

Building an application using HttpHandlers to serve pages may be fast when serving static content, but if you plan to use some sort of templating to serve dynamic data, you're going to cause yourself a lot of undue work. As for performance, it's hard to say with this option because your templating could be nasty or possibly not.




回答5:


ASP.NET MVC, Web Forms and the Generic Handler (.ashx) are all HttpHandlers implementing the IHttpHandler interface.

Out of these options the Generic Handler (.ashx) would be the most lightweight.




回答6:


ASp.NET MVC is as close as you can get to HtTP and Html.




回答7:


You should use MVC, because you have a lot of more control about the generated client code than in WebForms, and is simpler than ashx handlers.




回答8:


MVC very much gives you more control over HTML produced. So, from a bandwidth perspective, it definitely has better performance. With this may also come conciseness of code to generate this HTML.

However, MVC doe not improve business/data layer, or database performance, it just separates them. If you want to analyze, having multiple layers does not improve performance, just the structure of the program, which in turn may lend itself to methods for adding more performance.

A down side to MVC is learning how to think MVC and learning how to use the framework. If that is not an issue, go for MVC, it will teach you some good habits, if you don't have them already.

And finally, HTTP Handlers are not really meant for being used in this way, they are for things like file proxies.



来源:https://stackoverflow.com/questions/856006/asp-net-mvc-vs-webforms-vs-http-handlers-ashx-which-is-the-most-lightweig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!