Last post Apr 11, 2010 11:02 PM by ritzh
Mar 25, 2010 05:08 AM|Chithra_Iyer|LINK
I am having a web application in asp.net 3.5 . Now i need to convert / re architecture / redesign that application to the asp.net mvc framework2 web application.
I have downloaded the framework and working in my system.
The existing project has the following parts.
1) database (in sql server 2005) with tables and stored procs.
2) aspx pages and its code behind
3) WCF service contains all the business logic classes.
The new asp.net mvc 2 framework has three folders like model view and controller.
Pls help me to decide what shoould come in which folder?.
As per my knowledge, the db paert should come in model. But all my business logic classes are in a separate wcf service.Do i need to create that service in controller? Then where i can include the code behind code.
Pls help me.I am totally confused.
Thanks in advance,
Mar 25, 2010 05:40 AM|XIII|LINK
it seems to me you're already in a layered architecture so that's already great.
The folder that you need are the Controller and View folders to place the specific MVC implementations in. From the controllers you can call your WCF services which expose objects with your business model in. For flattening these out before sending to the
view I would suggest you map these to ViewModel objects which can go in the Models folder.
Your database certainly doesn't belong in the MVC project which is purely a presentation layer. Keep that far behind the WCF service layer like it is now in your current project.
Mar 25, 2010 06:03 AM|Chithra_Iyer|LINK
Thanks a looot for your quick reply .
again i am having some more doubts
Do i need to create a new solution and add the existing code to that?
or Just add empty folders(view, controller,model) to the existing solution?
and calling wcf service from the controller folder means?Do i need to create a class in that and call the service from there. ?
Can you pls provide me a sample ?.
This is my first project in mvc2 framework, thats why this much questions....sorry
Thanks, in advance,
Mar 25, 2010 07:56 AM|XIII|LINK
you can gradually upgrade your existing ASP.NET application to MVC in the same project if you want so yes. If you want to rewrite it from scratch I suggest you simply create a new project based on the MVC template. In the Controllers folder come your controllers.
These are classes with methods which are exposed as actions. From within these you can call your WCF services which hide the rest of your business/data access logic so you can keep that the same.
I get the feeling that you're trying to grasp the basics of MVC so I suggest that you first read a book about it or check out some tutorials you can find under the MVC tab on this site. It'll help you to get started and to make the right decisions as you
go along. I recommend reading ASP.NET MVC in Action and ASP.NET MVC 1.0 quickly.
Apr 11, 2010 11:02 PM|ritzh|LINK
Where would the backend code for the views go? This backend code is visible to the view and the view can call functions from it while it is running (for example a post back) therefore how would we implement this in MVC if we do not want to create WebUserControls
and just want to use normal user controls and view pages?