Last post Oct 31, 2015 02:00 PM by NiyaziToros
Oct 31, 2015 08:16 AM|NiyaziToros|LINK
I already created my MVC 4.5 solution. Used Microsoft Identity with my existing Sql Server database. Now I want to add Web Api 2 into my project. My question is
should I add seperate WEB API 2 into my solution or just add web services in to my solution?
Oct 31, 2015 10:06 AM|Mukesh_Kumar|LINK
You need to put your WEB API in different project. I would only separate Web API into a separate project if you are going to build a proper API for your online service - perhaps to be consumed by external customers, or by various devices - such as
fueling your mobile apps.
The reason behind this is that..
Many of the concepts used by Web API and MVC, even though similar at first glance, are actually not compatible. For example, Web API attributes are System.Web.Http.Filters.Filter and MVC attributes are System.Web.Mvc.Filter -
and they are not interchangeable.
Same applies to many other concepts - model binding (completely different mechanisms), routes (Web API uses HTTPRoutes not Routes, even though they both operate on the same udnerlying RouteTable), dependency resolver (not compatible) and more - even though
similar on the surface, are very different in practice. Moreover, Web API does not have a concept of areas.
Ultimately, if all you are trying to do achieve is to have a "new, trendy" way of serving up JSON content - think twice before going down that path. I certainly wouldn't recommend refactoring any existing code unless you are really looking into embracing
HTTP and building your app in a RESTful way.
It all really depends on what you are building. If you are starting a new project, and all you need is to serve up some JSON to facilitate your web app - provided you willing to live with some potentially duplicate code (like the stuff I mentioned above),
Web API could easily be hosted within the same project as ASP.NET MVC.
Hope this will help you.
Oct 31, 2015 02:00 PM|NiyaziToros|LINK
Thank you Mukesh,
I have already made a MVC web app. Administrator and User will use this MVC Web App for some CRUD operations.
Customer use their NFC enable Mi-Fare Loyalty card to send authentication information to SQL Server database using POS terminal. (Card information and user 4 digit pin)
Then SQL Server database looks at the information that comes from POS terminal, process the information and send back some authorization with Loyalty information.
I will add separate MVC WEB API 2 project to my solution.