Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 834603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:41:50+00:00 2026-05-15T04:41:50+00:00

I may have the wrong pattern here, but I think it’s a fair topic.

  • 0

I may have the wrong “pattern” here, but I think it’s a fair topic.

I have an ASP.Net MVC application in which it calls out to a WCF service to get back the ViewModels that will be rendered. (the reason it’s using a WCF service is so that other small MVC apps may also call on for these ViewModels…only internally, it’s not a publicly available thing so I can change anything either side of the service. The idea is to move the logic that was in the website, closer to the server/database so the roundtrips aren’t so costly – and only do one roundtrip overall from the webserver to the database server).

I’m trying to work out the best thing to return these “ViewModels” in from the service. There are lots of common little bits of functionality, but each page may want to display different subsets of these things (so homepage maybe a list of tables, next page, a list of tables and users that are available).

So what’s the best way of returning the information that the page wants, hopefully without the webservice knowing about the page?

Edit:

It’s been suggested below that I move the logic in process. This would be a lot faster, except that’s what we’re moving away from because it is actually a lot slower (in this case). The reason for this is that the database is on one server, and the webapp is on another server, and the webapp is particularly chatty at points (there are pages it could end up doing 2K round trips – (I have no control over reducing this number before that’s suggested)), so moving the logic closer to the db is the next best way of making it more performant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:41:51+00:00Added an answer on May 15, 2026 at 4:41 am

    I would look at creating a ViewModel per each MVC app/view. The service could just return the maximum amount of data for the “view” in a logical sense and each MVC app uses the information it wants when composing the ViewModel for it’s view.

    Your service is then only responsible for one thing, returning data specific to a view’s function. The controller of each app is responsible for using/not using pieces of the returned data.

    This will be more flexible as your ViewModels may require different validation rules as well. ViewModels also have MVC-specific needs(SelectList etc..) that shouldn’t really be returned by a service layer. It seems like something can be shared at a glance, but there are generally lots of small differences that make sharing ViewModels a bad idea.

    class MyServiceViewResult
    {       
        public int SomethingEveryViewNeeds { get; set; }
        public bool OnlyOneViewMightNeedThis { get; set; }
    }
    
    class ViewModel1
    {
        public int IdProperty { get; set; }
    
        public ViewModel1(MyServiceViewResult result)
        {
            IdProperty = result.SomethingEveryViewNeeds;
        }
    }
    
    class ViewModel2
    {
        public int IdProperty { get; set; }
        public bool IsAllowed { get; set; }
    
        public ViewModel2(MyServiceViewResult result)
        {
            IdProperty = result.SomethingEveryViewNeeds;
            IsAllowed = result.OnlyOneViewMightNeedThis;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I may have the wrong idea with this but bear with me... I have
I have a text field. If it has wrong values then it may show
I'm new in unit testing so may be I do something wrong. I have
Firstly, Modifying may be the wrong term, I see a few people have posted
I have a csv file which may have empty or blank rows. I want
I have a multidimensional points which may have keys of the following 3 types
my application may have more then one users on the same phone, and i
I think I may have encountered a bug in mysql, or is it just
ETA: Turns out I may have the wrong end of the stick. Collabnet SVN
You may have heard of PawSense , a Windows-only utility that prevents keystrokes from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.