Using WCF with wsHttpBinding with Web Forms vs MVC
I have used WCF in the past with my Webforms so my solution was
MyWebformApp = WCF(Model+business) + Web Forms
So when I want to work with the MVC for 开发者_开发技巧presentation arch. How do u use WCF with ASP.net MVC ? Are your data contracts a part of the model ? How do you register the datacontracts as properties?
Roughly here are a few steps:
- Create a proxy of the service using svcutil.exe and include it in your application
- Create an interface which will abstract all the necessary methods you need to call from the application (IRepository)
- Implement this repository and call your WCF service (work with the generated client)
- Inject the repository into the controller constructor
- In the meantime think about the view models you would set and the mapping between the objects coming from the web service and those view models.
精彩评论