asp.net MVC Web API VS asp.net MVC 4 & MVC 3 internet application - asp.net-mvc-3

i read about the beta version of asp.net MVC 4 web API , i think that it is related to building web services. So are these two frameworks (MVC 4 internet application & Web API) targeting different types of application or they may be used for building similar types of application but using different frameworks?
for example if i need to build an internet application for a registration system for a university or an internet shopping store (which i use to develop using asp.net MVC 3 internet application),, then will these two frameworks be suitable for these types of applications ???
Thanks for any help ...
BR

Those are just 2 templates. No matter which one you choose when creating the application initially you could always later change and add functionality. The MVC 4 internet application template is similar to the ASP.NET MVC 3 internet application template. It creates a default Home and Account controllers, it registers a default route and adds a couple of views.
The Web API template in addition to all this it adds an API route and an ApiController allowing you to expose RESTful APIs in your web application. The Web API is basically a simplified way to build RESTful services. Up until now this was possible with WCF but the Web API makes it really simple. The Web API could be self hosted. You don't need to put it in an ASP.NET MVC application.

The webapi makes it simple to create HTTP services. I have only used them to return json. You can use either for the types of applications you are building.
Take a look at this blog article from Scott Guthrie http://weblogs.asp.net/scottgu/archive/2012/02/23/asp-net-web-api-part-1.aspx

Web Api basically lets you create HTTP REST full services. The API also gives one full access to the http requests and responses in a type safe way.

Related

ASP.NET Core Web API vs ASP.NET Core Application

First off, I apologise if this is a trivial question but I am getting so confused by the information I am reading. I have put off posting on here as I feel my question is too broad but I can't find a definitive answer. I am a C++ developer by trade but I am wanting to get into web development.
My end goal is to have a web API that is consumed by both a web app and mobile app. I want to get the structure nailed first by developing an web API and web app and then expand it to a mobile platform later on.
My aim is to have 4 separate sections - Database -> WebAPI -> Web App
-> Mobile App
all of which are protected with username/password etc.
I have decided to use ASP.NET Core but when creating an application I am given two options in visual studio - ASP.NET Core Application or Web API. I have tried creating a Web API and a separate Core Application but can't work out how to call the web API. I have also tried creating a Core Application as it seems like I should be able to do everything I want in one project but I am worried that the Web API won't be separated enough to be able to call from a mobile app.
I will be working with a database containing sensitive information so obviously want to protect access to the Web API and Web/Mobile app. I have been watching courses on Pluralsight about Identity but I have read that it doesn't work well with Web API's.
Basically I am getting extremely confused when in my mind my end goal should be relatively simple to achieve. If anyone could give me any pointers as to what technologies I need to use would be fantastic.
ASP.NET Core WebAPI is specifically designed for building REST-ful services.
ASP.NET Core Application is used to create web applications that returns both views and data (it's an analog of Asp.NET MVC from standard Framework).
Which to choose is really depends on kind of WebApp you are going to use. If you plan to use some SPA framework, you don't need mechanisms to generate views on server side - WebAPI is a great choice, otherwise choose Application. Here you can find more details on differences.
As of security concern, there no issues with WebAPI. It provides a lot of mechanisms to secure your API and restrict access to methods based on user's identity. Please look at this article as an example.

API Driven Approach Vs Non-API approach

I am to start designing & architecting a fairly big database business application (data entry, notifications, reporting, data export and usual security restrictions for data). Multiple clients - mobile apps & multiple websites will be there. Plan to use Asp.net MVC5 & Sql server for the development. Phonegap will be used to create mobile apps.
I plan to create an API. All interactions to the Database will be through the API (a REST API). This REST API will be created using Asp.Net MVC5. The front end will be developed as an HTML5 App which calls this API using AJAX. All interactions with the API will be through AJAX calls. Need to expose some of these services (5%) to third parties also.
For e.g. for a supplier management feature, there will be services like SupplierAdd, SupplierEdit, SupplierDelete, SupplierList etc. in the API. HTML5 App will call them through AJAX and do required. Necessary security will be imposed for these services using a login and token based security system.
Plan to use some Javascript frameworks like Angular JS for front end.
The entire application is one with around 200 DB tables and lot of relationships between DB tables. Business logic is only moderately complex. This is mainly a data storage & reporting application.
Is there any problem with this full API based approach ?
Another approach suggested is to avoid AJAX and Javascript and use ASP.Net MVC itself. No separate API will be there for each operation. .cshtml will submit to the controller method and this method will call the Business Layer and do operation. Services which are needed for mobile apps and third parties alone are exposed as API. Is this a better solution ?
The issue which I see for the second approach is that when more and more mobile applications or websites come in future, it does not offer needed flexibility. Also, exposure of some of the services to third parties will be difficult.
I request experienced architects to comment.

MVC .NET or WEB API

We want to write a new web site for customer using SQL DB
and implement only one specific client.
what the recommended technology to be used:
Peure MVC.net
Web API and client side using AJAX
I will be glad to hear the causes, the consideration and the cost.
Thanks!
I tend to favour a web api to handle all of the database work (via entity framework), but use MVC for my front end application.
This way you have all the flexibility of an API should you want to use different frameworks in the future (Angular, ASP.net 5 etc), but you can still have the pleasure of working MVC in your front end site.

Can you build an ASP.NET Web API on top of OWIN?

Well the title basically sums it up, I'm wondering if I can create an OWIN pipeline to my ASP.NET Web API. I want to do this so I can apply a base security layer that I can apply to all of my API service hosted on my service server. New to OWIN, love the idea
Yes. You can start with this http://nuget.org/packages/Microsoft.AspNet.WebApi.Owin/0.21.0-pre and then you will need an another package depending on what host you choose.
You will find below link helpful. It using Katana, an OWIN implementation for Microsoft hosts and the Web API framework.
http://www.strathweb.com/2012/12/running-aspnet-web-api-with-owin-and-katana/
Yes.
Also: If self-hosting Web API 2 using OWIN in a windows service, you can check out this example on GitHub: https://github.com/danesparza/OWIN-WebAPI-Service
It walks you through creating the service, adding OWIN using NuGet, and using attribute based routing in Web API 2.

Server-Side State Management in ASP.NET MVC

I am in the process of migrating an ASP.NET web forms application to ASP.NET MVC 3. In my web forms project, we use the Application object to store some temporary information that we want to pass around on the server. We do not want to pass this information back to the client.
My question is, is there an equivalent to the Application object in ASP.NET MVC 3 to handle server-side state management?
Thank you!
Yes, the "object" is the same and can be accessed in a similar manner. MVC is built "on top of" ASP.Net so you can expect to have access to most of the same data structures like HttpContext.Session and HttpContext.Application.

Resources