ASP.NET MVC and Web Services

Does adding a web service to my ASP.NET MVC project affect the whole concept of MVC?

This web service (WCF) depends on the model level on my MVC project for interacting with internal content (so it seems to me that it should be part of the MVC solution).

Should I add this to the controller or model level?

+47
architecture web-services asp.net-mvc wcf
Sep 23 '08 at 3:24
source share
7 answers

It looks like you should split your model into your own assembly and reference it from your MVC application and WCF application.

  • YourApp.Data - Shared Model and Data Access Available
  • YourApp.Web - If you want to share more with your web applications
  • YourApp.Web.Mvc
  • YourApp.Web.WebService

If you want to use WebServices MVC style, perhaps you should use MVC to create your own REST application.

+27
Sep 23 '08 at 14:23
source share

Is there any specific reason why you need to add web services to your MVC application? Unless there is a specific reason, you should use your controllers in RESTful in the same way as the RESTful web service.

Send a message from Rob Connery for more information: ASP.Net MVC: Using the RESTful Architecture

+19
Sep 23 '08 at 3:36
source share

Dividing the model into your own project does not violate the "MVC" pattern. First of all, it's just a pattern. The purpose of the MVC pattern is to clearly define between your data, data handlers and masters, and how you interact between them. The best way to do this is as Seb suggested:

  • YourApp.Data li>
  • YourApp.Web.Mvc
  • YourApp.Web.WebService

Something that can help you is the MVC Storefront, which Rob Conary gathered with. Watch the video here:

MVC Storefront Video Series

And if you want to see the actual code in your browser to quickly see how it did, go here: MVC Storefront Code Code Browser

+11
Feb 25 '09 at 14:11
source share

I don’t think that dividing a model into its own assembly has anything to do with whether you use MVC, you still have a model. Where is it inappropriate?

+2
Oct 03 '08 at 10:08
source share

Everything worked out for me.

Check out my result on my blog.

ps: I don’t think this would violate the concept of MVC if you think the web service is a repository model because all web services return an XML dump.

+1
01 Oct '09 at 2:52
source share

I have added web services to my application and it works well. I do not think this violates MVC, because it is an alternative interface to your model. MVC is not suitable for web services because web services have no representation.

0
Sep 23 '08 at 5:09
source share

Think of web services and databases as the same. According to this analogy, I think it makes sense to post your actions in web services where you host the database logic.

0
Mar 22 2018-11-11T00:
source share



All Articles