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

  • Home
  • SEARCH
  • 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 8240649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:33:36+00:00 2026-06-07T20:33:36+00:00

If it was decided to use WebAPI to create a service layer to be

  • 0

If it was decided to use WebAPI to create a service layer to be used for a variety of clients. What would be the best way to architect the web client?

As WebAPI is web-friendly it would be possible to consume this directly from the client using javascript. However I would worry that this can get messy fairly quickly and javascript is not the easiest technology to unit test.

An alternative would be to use the HttpClient class to call the REST services from MVC controllers. Is this a valid approach?

I suppose that the two approachs above could be combined but I would worry that this would get messy. Would you agree that it would be better to go with one approach or the another?

Sorry I have seen many posts on whether to use WebAPI or MVC but none on combining the two.

Thoughts?

  • 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-06-07T20:33:39+00:00Added an answer on June 7, 2026 at 8:33 pm

    An alternative would be to use the HttpClient class to call the REST
    services from MVC controllers. Is this a valid approach?

    Yes, absolutely. It’s just that this code should not be put in your controllers but rather in your DAL layer, because controllers should not know where the data comes from (flat file, database, Web API, …).

    So there are 2 approaches:

    • You decide to consume your Web API from your MVC client application using the HTTP protocol. In this case you create an implementation for your repository (DAL layer) that will use the HTTP client and return directly the domain models
    • You decide to directly consume the services contained in this Web API without sending HTTP requests. In this case you reference the assembly containing the service layer for your Web API in your MVC client application and directly this assembly becomes the service layer for your MVC application. In this case the Web API through HTTP serves for other clients: javascript, mobile, …

    Which approach you choose would really depend on your specific scenario and requirements. Do you need to support interoperable clients other than your MVC client application? In any case start by defining a service layer in a separate assembly containing your domain models and stuff. Then you could always expose this service layer through a Web API (or a WCF service or whatever) or directly reference it from .NET clients.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've decided to use this.variableName when referring to string/int etc.. fields. Would that include
I am working on a database access layer project and decided to use Linq
So I have decided to use XDocument to create a XML file, which was
We decided to use mongodb for some web application (instead of mysql) but want
I decided to use jquery to create the duplicate of dropdown menus instead of
I've decided to use the 960 grid for a project and would like some
We decided to use Linq To SQL for our Data Layer on our most
Decided to use Apache's Common Configuration package to parse an XML File. I decided
I've decided to use Entity Framework for O/R Mapping, and DataAnnotations for validation in
My capstone team has decided to use Qooxdoo as the front end for our

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.