probin anand
probin anand

Reputation: 134

Is there anything in MVC that can't be implemented in webform

I have been doing research on the internet on things in MVC that can be implemented through the webform. I have found many articles and like to consolidate things.

1 loosely coupled architecture in MVC can be implemented in webform by implemented similar folder structure for web forms. i.e, keeping aspx in view folder, models in model and custom controller in controller folder. Something that is similar to the aspx view in MVC 2 and 3 using aspx views.

2 MVC URL routing can be implemented by creating a URL rewrite in web forms.

3 unit testing in MVC can also be implemented if we create service that are unit testing friendly and consumes those service in web forms.

4 Dependency Injection can also be achieved using the webform.

5 MVC easiness to support external jQuery libraries can also be implemented using web API in the webform.

6 the problem of view state and event binding of webform server-side controls can also be removed if we use HTML controls in webforms. ( Much easy after webform 4 in .net framework 4.5)

7 we can easily communicate from.webform to MVC controller and vice versa if a project has both web forms and MVC in it.

Can anyone point out anything in MVC that can't be implemented using webforms or contradict with any of the statement made above?

Thanks

Upvotes: 1

Views: 72

Answers (1)

V0ldek
V0ldek

Reputation: 10563

The question of "can a thing from Y be implemented using X" is usually trivial - the underlying language, C#, is Turing-complete, so you can implement anything that realistically could be implemented in any technology using it. You could also implement anything from ASP.NET MVC, or Webforms for that matter, using plain old C or Assembly. Your points basically state that you can simulate features of ASP.NET MVC in Webforms by writing a ton of boilerplate code. Well, you could, obviously - you could do the same using C, couldn't you?

Also, as for point 1, I don't find "implementing a similar folder structure" a compelling argument for a loosely coupled architecture. Folder structure is hardly architecture. MVC exists, because it allows for an easier separation of concerns. Out of the box, Webforms does not support MVC. You're making your request straight to your Page, there's no Controller. Folder structure will not solve this issue. You'd have to try really hard and write a lot of code around the issue to implement MVC, basically write a framework on top of a framework. That's what we usually call "reinventing the wheel".

The question boils down to ergonomics and long-term support. Webforms has a lot of magic going on under the hood, which takes away control and makes implementing architectural patterns harder, and isn't really developed anymore. The focus is mostly on Razor Pages and ASP.NET Core MVC. If you like working with Webforms you'd probably find Razor Pages a better choice. Both of these frameworks are more modern and allow you to write less code to achieve clean, loosely coupled architecture.

As a side note on modern technologies, jQuery is about as modern as Webforms are.

Upvotes: 1

Related Questions