Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Things I cannot do in ASP.NET MVC

Are there some things I cannot do with ASP.NET MVC? Things that are only possible with ASP.NET WebForms, or extremely much easier with WebForms?

We consider using ASP.NET MVC for a new project. But I wonder if there are some obvious things we will not be able to do with ASP.NET MVC when compared to WebForms, or places where we will have to spend a lot of time with ASP.NET MVC.

like image 577
Ole Lynge Avatar asked Mar 29 '09 06:03

Ole Lynge


3 Answers

The biggest one would be using existing 3rd party controls on your form. Most of the inbuilt controls are pretty easy to reproduce, but if you have a pet 3rd party control, you might have to host that on a regular (non-MVC) aspx page (luckliy this is supported).

Likewise, "web parts"

Also - the feature where ASP.NET uses different html for different clients (mobile, etc) becomes... different; you wouldn't want to do this by hand, but in reality most clients now work with standard html, so it is less of an issue in the first place.

Some things like i18n via resx files need extra work than is in the vanilla MVC template, but the samples are there on the internet.

One point... MVC is licensed only for MS/ASP.NET; so one thing you can't do (without violating the terms, as I understand it) is to run it in mono/Apache - but IANAL.

Now consider the things you can do with MVC, that you can't (or are hard) with vanilla:

  • routes instead of pages
  • automated input resolution (action arguments)
  • proper html control...
  • ...enabling jQuery etc for simple AJAX
  • separation of concerns
  • testability
  • IoC/DI
  • multiple templating options (not just aspx/ascx)

re input resolution:

public ActionResult Show(string name, int? page, int? pageSize) {...}

will pick "name", "page" and "pageSize" off (any of) the route, query-string or form - so you don't have to spend lots of time picking out request values.

re templates - aspx/ascx aren't the only templating options. For example, see here; or you can write your own if you like... The view is not tied to ASP.NET controls at all.

like image 81
Marc Gravell Avatar answered Nov 19 '22 08:11

Marc Gravell


Validation is not as easy as in WebForms. In Webforms you can add a validator and just set a property that enables clientside validation. You can localize the errormessage. The localization works clientside and serverside.

There is no out of the box clientside validation in MVC and you need to find a way to localize clientside errormessages.

Localization itself is different. Ressources obviously by default dont exist per page, because there is no page. But there is a good way to have ressources per view.

I still did not check, if it is possible to set SSL-required per folder.

EDIT

The story is different with MVC3. There is a good validation support now.

There are still things that are not implemented in MVC. The biggest issue for me is a complete implementation for donut cashing and partial cashing. There is some improvement in MVC3 in this area but it is still not complete. Anyway stay tuned: the MVC team seams to be aware that this is something they should work on.

like image 23
Mathias F Avatar answered Nov 19 '22 09:11

Mathias F


The big one is Controls. User Controls are not available with ASP.NET MVC. I have even gone so far as to try using code like this:

new Label().RenderControl(...ResponseStream...);

No dice.

Of course, as a part of that, there is no need for view state, so that isn't in there.

Server controls do work, though.

like image 1
JoshJordan Avatar answered Nov 19 '22 07:11

JoshJordan