MVC vs Webforms

Soldato
Joined
25 Mar 2004
Posts
15,902
Location
Fareham
Hey all,

I have an internal site at work that is backed by an MS SQL backend, the SQL server contains tables that are filled up by some scripts that run periodically, there is no user input it is view only data (nor would I want users to be able to input data into the tables).

The site is currently using C# ASP.NET with webforms, some javascript and CSS styles for the frontend. I am 90% of the time calling data using Stored Procedures which accept input parameters, and allows for paging the results - I can return thousands of rows

On my pages I am generally calling data using TableAdapters to link my Stored Procedures, with ObjectDatasources binding to the TableAdapters, and then binding the ObjectDatasources to Gridviews so that the user can see the results. The ObjectDataSource allows for paging results automatically which is nice, along with the Gridview paging bars.

Question is can I do similar with MVC here, and easier? I have been playing with some of the MVC tutorials but I am struggling to see how to do what I want in MVC vs how I am doing it now in webforms, a lot of what the tutorials have done so far has been for things like code first databases, or focusing on how users can input data, validate it etc.

The demo stuff I am working with is too small compared to my live data, and my queries are often spanning more than one table so I am a little lost/confused on how MVC is meant to work with this and Entity Framework.
 
Soldato
Joined
11 May 2011
Posts
2,901
Location
Farnborough
So you could do the same thing using MVC very easily,

You would just call some sort of Repo layer from the controller down to the data adapter, usually I use SqlDataReader class and then pass that back up to the View (populating the model and pass that model to the view) you could then do all of your data formatting really easy in the view.

A great thing about using MVC with complex types is that you don't need to debug your output to see ASP .Net is generating, depending what you needed to do but you can bypass a big WebForms limitation by having multiple forms on a single page/view.

I wouldn't say MVC is a WebForms killer but give it a go. vNext is going to be interesting.
 
Soldato
Joined
27 Mar 2003
Posts
2,710
Hey all,

I have an internal site at work that is backed by an MS SQL backend, the SQL server contains tables that are filled up by some scripts that run periodically, there is no user input it is view only data (nor would I want users to be able to input data into the tables).

The site is currently using C# ASP.NET with webforms, some javascript and CSS styles for the frontend. I am 90% of the time calling data using Stored Procedures which accept input parameters, and allows for paging the results - I can return thousands of rows

On my pages I am generally calling data using TableAdapters to link my Stored Procedures, with ObjectDatasources binding to the TableAdapters, and then binding the ObjectDatasources to Gridviews so that the user can see the results. The ObjectDataSource allows for paging results automatically which is nice, along with the Gridview paging bars.

Question is can I do similar with MVC here, and easier? I have been playing with some of the MVC tutorials but I am struggling to see how to do what I want in MVC vs how I am doing it now in webforms, a lot of what the tutorials have done so far has been for things like code first databases, or focusing on how users can input data, validate it etc.

The demo stuff I am working with is too small compared to my live data, and my queries are often spanning more than one table so I am a little lost/confused on how MVC is meant to work with this and Entity Framework.

You can do this in MVC as easily as webforms.

As someone who has been through the webforms to MVC transition I found the change very daunting and confusing in equal measures.

The safety of having control components that can be dragged and dropped like winforms meant you could build a site very quickly and some pretty complex things quickly out of the box but once you wanted to extend that functionality it could get a bit frustrating especially when events fired in the wrong order.

With MVC you don't have to completely abandon your "data access" ways so if you are happy using ado.net continue using it while getting to grips with the MVC architecture and then introduce an ORM technology later. Remember that these are not the panacea for all situations and sometimes using specifically crafted sql is better than the ORM generated sql.

For me the most difficult thing was understanding the razor syntax and how this integrated with html as my front end skills where ok but not brilliant. I had already started to try and separate my code into distinct layers where I could to try and keep the code behind pages as clean as possible.

If you are looking for some of the webform equivalent controls for MVC then take a look at Telerik's Kendo UI as they provide a load of pre-built MVC controls (some are only available to pro license users) but these really helped me to get to grips with the modern MVC world quickly and softened the change from webforms.

I hope my ramblings have helped and if you need any more info I'll be happy to help.
 
Soldato
OP
Joined
25 Mar 2004
Posts
15,902
Location
Fareham
It would really help if either of you would be able to spend a little time with me answering some questions/giving some pointers maybe?

Or maybe I can provide some kind of a source with a description of what I want, and see what you guys can do with it? I wouldn't need anything massively complex as most of my pages work in the same fashion, so one example would allow me to go forth and work out the rest I reckon!
 
Back
Top Bottom