Tomas Walek Tomas Walek - 1 year ago 104
ASP.NET (C#) Question

Defining a WebAPI route without the /api/{controller} prefix

I want to process requests in format without the /api/{Controller} prefix (e.g. by a WebAPI controller method. Is it even possible or do I need do switch to MVC controller? I Defined the following route:

name: "Check",
routeTemplate: "download",
defaults: new { controller = "Download", action = "CheckAccess" });

but unfortunately it is not working, the controller doesn't even gets created (I have traces in the constructor)

Answer Source

Try attribute routing ( only available in web api 2)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download