Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web Api as a standalone project in one solution

If i want to use WebAPI as a service to connect to multiple databases on different servers and retrieve the data that my MVC application will use what is the best way to do it?

I don't want do have ApiController(s) in the same project as my MVC project so do i need to add a new WebApi project (delete all except controllers and stuff that the template adds to have a clean project) that my MVC application will reference?

Here's the list of tutorials/blog posts i used to learn about WebAPI:

ASP.NET Web API - Screencast series with downloadable sample code http://weblogs.asp.net/jgalloway/archive/2012/03/16/asp-net-web-api-screencast-series-with-downloadable-sample-code-part-1.aspx

Consuming ASP.NET Web API Service using HttpClient

http://debugmode.net/2012/03/03/creating-first-http-service-using-asp-net-web-api-part1-of-many/ http://debugmode.net/2012/03/07/consuming-asp-net-web-api-service-using-httpclient-part2-of-many/

CRUD operation using ASP.NET Web API and MVC4

http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet-web-api-in.html http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet-web-api-in_28.html

Creating a .Net queryable client for ASP.Net Web API oData services http://blog.petegoo.com/index.php/2012/03/11/creating-a-net-queryable-client-for-asp-net-web-api-odata-services/

Using HttpClient to Consume ASP.NET Web API REST Services http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/

Client side support with the ASP.NET Web API https://msmvps.com/blogs/theproblemsolver/archive/2012/03/13/client-side-support-with-the-asp-net-web-api.aspx

Create and Consume ASP.Net Web API REST Services - MVC4 http://www.askamoeba.com/Opensource/Opensourcedetail/144/Create-and-Consume-ASP-Net-Web-API-REST-Services-MVC4

Building and consuming REST services with ASP.NET Web API using MediaTypeFormatter and OData support

http://robbincremers.me/2012/02/16/building-and-consuming-rest-services-with-asp-net-web-api-and-odata-support/

Using JSON.NET with ASP.NET Web API

http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx

Creating Custom CSVMediaTypeFormatter In ASP.NET Web API for Comma-Separated Values (CSV) Format

http://www.tugberkugurlu.com/archive/creating-custom-csvmediatypeformatter-in-asp-net-web-api-for-comma-separated-values-csv-format

Implementing CORS support in ASP.NET Web APIs

http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx

How I see Web API

http://thedatafarm.com/blog/asp-net/how-i-see-web-api/

like image 892
Matija Grcic Avatar asked Apr 13 '12 11:04

Matija Grcic


1 Answers

You may use a completely different project to host your Web API controllers. Yet in this case you need to think about the deployment.

Web API is just a web project. It will have its own config file. It will be likely that it will run in its own worker process (depending on how you deploy it).

So if you partition the Web API out, then you get more flexibility but you might end up duplicating a lot of config.

My advice is that, if you do, make sure both projects talk to the same base services projects. Partitioning can also make sense if this Web API might be used by third parties.

like image 71
Aliostad Avatar answered Oct 14 '22 16:10

Aliostad