0

I'm beginning in programming and I have an "asp.net mvc Web api" that provides Json that is consumed for an android application. The android app has a login, and a crud connected to a mssql server db. Now I want to build a web site/application that also consumes that json my question is if can I use the same asp mvc web api project and just added the views needed and consume the same ActionResults and methods of controllers and models respectively or must I create a new asp.net mvc project for the website. Other question is if the web application must consume its own methods that provides json from the web api or can consume the same data of the methods that uses the web api for the android application? mainly is a conceptual question what i'd like to know if can i use the same project in the following image for building the web Api and the web application (both in asp mvc) as asp mvc uses the same structure for building a web api and for a web application

enter image description here

lumixel
  • 167
  • 3
  • 11

2 Answers2

3

You should create another project, which will include a MVC application, which will not be a Web API.

These are 2 differents kind of projets and should be separated. Exemple: MVC vs Web API

Here is another topic talking about the difference: Difference between MVC 5 Project and Web Api Project

To answer the second part, What you could do is to access your Web API from your MVC application, that way it consumes the same data as the android app does.

Community
  • 1
  • 1
Xavier
  • 440
  • 4
  • 11
  • ok so the new web project in asp mvc for the web application has to consume the json data of the web api via http like does the android application? – lumixel Jun 24 '15 at 02:26
  • 1
    You don't have to. You can for example use sql / msql driver to access your database, the same way you do it on the Web API. But you can, make view using Ajax refresh, and then re-use the web api json. – Xavier Jun 24 '15 at 06:21
1

Are you asking if both your new web site and your Android app should use the same API to your backend database? In general I'm a fan of this approach if you plan on having multiple different clients consume the same data.

Read this article for a little more background..

Buddy
  • 10,874
  • 5
  • 41
  • 58
  • yes that is the second part of the question, the first is if can I use the same project to build both the web api and the web site. – lumixel Jun 24 '15 at 14:19