Differentiate between MVC and WebAPI in ASP.NET 5 / MVC 6 - asp.net-web-api

MVC and WebAPI are being combined for ASP.NET 5 / MVC 6, however I still want to be able to differentiate between the two.
Previously, different behaviours could be implemented in the form of global filters, on both MVC and Web API.
Now the two are combined in MVC 6, how could I cause a global filter to only apply its behaviour for Web API actions?

You can separate the controller types by namespace or assembly. Create a custom filter provider that extends the DefaultFilterProvider class. The provider would check the controller namespace and return the appropriate action filters.

Related

common logic in multiple actions in Web API controllers

There is a similar question already asked by someone BUT it was related to ASP.NET MVC and not Web API. I have some common code which I want to execute in every action in Web API certain controllers. What is a good way for such situation?
ASP.Net Web API and ASP.Net Wep MVC has the same core. Also you can use the same answer describe in your link :
creating a BaseController and inherit all your controllers
creating an ActionFilter like here

Action Filters In MVC

I want to create an action filter in mvc that can be used in multiple mvc applications. Can we create actionfilters in MVC in a class library and reuse them in multiple mvc applications?
According my study it is not possible to create Action filters in a class library and reuse them in multiple MVC applications

ASP MVC 5 WebAPI vs Ajax.ActionLink

I am having some difficulties understanding the difference between ASP.Net MVC WebAPI Controllers (System.Web.Http.ApiController) and #Ajax.ActionLink (PartialViews).
As my knowledge of MVC 5 and razor is not very profound I wonder why I should use ApiController (except for the obvious reason, when I have an external application that requests data from my webapi).
My requirement is to easily do ajax AND leverage the built-in mechanisms like validation and such.
At this time I use WebApi and jQuery - which works pretty well, but on the other hand i have to do all the exception handling (ie. validation) manually again.
Any advice?

Execution sequence of MVC Routes and HTTP Modules

Does the handler for MVC Routes trump the HttpModules defined in web.config?
I have an asp.net app that consists of legacy webforms code and MVC code. I want to prove to myself that MVC is taking precedence for handling requests over a custom HttpModule the project uses, which can also handle requests.
IIRC the MVC routing is done in the HTTP module which launches MVC. So MVC will "win" as long as it's http module is added before your custom one.
I was almost correct. MVC implements a UrlRoutingHandler which means that it will direct the request before any module is invoked.
Source code:
http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/5b4f63fa0b89#src%2fSystem.Web.Mvc%2fMvcHttpHandler.cs

ASP.NET MVC 3 - How to Reuse Solution?

What's the best way to structure the base functionality of an ASP.NET MVC 3 solution so it can be reused in subsequent solutions? For example, I'm going to develop a basic skeleton MVC app with user registration using email verification, enhanced users/right/roles, blogging with comments, and a forum. I understand maintaining the business logic in class libraries but how about the controllers and views? Do I basically have to just copy and paste my base solution to create each of my new solutions?
Creating a Custom ASP.NET MVC Project Template
templify

Resources