2

I have to create application using ASP.net MVC , Web API and Jquery for API Call.

Now Question are :

1) Which Controller do I have to use if API Controller or Simple Controller?

2) How can I make my project structure best way?

If I use API in Different Project, than I have to use just Ajax call for that, but how can use Razor and Models of MVC Features?

and

If I use Controller as API Controller in MVC Application, than how can I use Model and Views in the Application?

2

1 Answer 1

1

Since no one else has chimed in.

First, the link I already posted.

http://odetocode.com/blogs/scott/archive/2013/07/01/on-the-coexistence-of-asp-net-mvc-and-webapi.aspx

There are alot of "overlapping" terms between the two.

Heck, I still find it hard to know which is which sometimes.

MVC is meant for the "web-tier". This is the tier that serves up pages to the end-user-browser. (I'm going for "most of the time" here, not every single use-case).

When you start a Mvc/WebApi project in Visual Studio, it (one of the templates) will mix MVC and WebApi in the same project.

This is NOT how it has to be setup, and my professional level apps I work on do NOT do it this way.

WebApi builds ~Services. This means "no Gui" ways of interacting with data (again, the most common use, not the exhaustive list)

My application is MVC, but it calls WebApi on a separate tier. Aka, I separated the 'mixture' of MVC/WebApi in the VS template.

Why would someone do this? Because right now, all I have are browser clients. BUT, in the future, if I need to write a smart phone app, all I need to do is create the presentation layer for that smart phone, and call my existing services I've already written with WebApi.

That's one way to look at it.

While the terms overlap, they are for different purposes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.