Click here to Skip to main content
15,891,645 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi Team,

I am creating web applications and planning to use following Microsoft technologies.
Please let me know your answer.

Create an application in ASP.NET MVC5 and write a restful service in WebAPI. Consume the service in a web application. This case web and service will be in different solution.
Please let me know your suggestions. Thanks in advance.

Regards,
Surendar

What I have tried:

Having this idea to implement in my web
Posted
Updated 13-Jun-17 22:54pm

1 solution

Yes you should put the two things in two separate projects in the same solution.
 
Share this answer
 
Comments
SurendarMani 14-Jun-17 10:16am    
Is it possible to implement consume the web api service from web mvc application via dependency injection
F-ES Sitecore 14-Jun-17 10:20am    
Not directly, no. You could abstract the calling of the web api into an interface and class and then inject that class using DI. So something like

public class MyConcreteClass : IMyService
{
public void DoSomething()
{
// calls the web API
}
}

You would then register MyConcreteClass as an implementation of IMyService and your MVC site (controller or whatever) would use IMyService and your DI would inject the appropriate MyConcreteClass

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900