?
Solved

best place to use a web service in MVC4

Posted on 2013-10-23
3
Medium Priority
?
247 Views
Last Modified: 2013-10-30
Hi, I have inherited a MVC4 application that was using a database to retrieve customer data, but now that information is available as a web service.

My confusion is should I access this web service in the ViewModel or should I go all the way to the Model?

pls note I'm new to MVC in ASP.net, not to mention MVC4.

thanks!
0
Comment
Question by:Mydeen Yussouf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39596288
A viewmodel is used to only represent the data of your view (hence the name). It would not make sense to call this data from such classes. Since the web service is effectively your data store, I would say that the model would be the place to retrieve your data.
0
 
LVL 1

Author Comment

by:Mydeen Yussouf
ID: 39599476
But what if the information gathered from the web service is only relevant to the view? Say a picture that is used in the view but never stored back in the model or in the underlying database? thanks!
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39600384
What if the service definition changes, or what if it comes from a different source? If the structure of the view is driven by what the user needs to see, regardless of the source, then you wouldn't want to couple your view to the underlying model (of the service). If you did, then any time the service definition changes you would have to change the view as well. If the structure of the view is driven by displaying whatever the service returns, then perhaps it would be OK to just display the model associated with the service, because if the service definition ever changed, you would have to update the view to accommodate the new or missing fields anyway.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question