I have an ASP.NET ‘traditional’ WebForms application and have just started exploring MVC 3, which is running within this project. Many of the existing WebForms pages build data structures such as DataViews and DataTables. My question is, how does one pass, for example a complex structure such as a DataTable to an MVC Controller?
I have an ASP.NET ‘traditional’ WebForms application and have just started exploring MVC 3,
Share
You shouldn’t pollute an ASP.NET MVC application with things like DataSets and DataTables. You should use strongly typed models. As far as passing complex models to an ASP.NET MVC controller action is concerned, the default model binder uses some simple rules about how the request parameters should look like. Here’s a blog post which illustrates some of them. And you could also POST complex objects as JSON format.
But in your particular case what I would recommend you doing is having the classic ASP.NET WebForms application pass just some id or a couple of arguments which would allow the ASP.NET MVC application use a repository layer and fetch the required data as a form of strongly typed models.