Things I cannot do in ASP.NET MVC

前端 未结 6 2188
轻奢々
轻奢々 2021-02-08 05:13

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 u

6条回答
  •  野的像风
    2021-02-08 05:49

    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.

提交回复
热议问题