clifford.duke
clifford.duke

Reputation: 4040

MapHttpRoute root url for web API

I am trying to change my root url of my web api to run an action, however when using attempting to map, I get an error at runtime saying that I cannot use / or ~ as my route.

config.Routes.MapHttpRoute("RootInformation", "/", new {controller = "Core", action = "GetInformation"});

How do I go about adding this root URL route

Upvotes: 1

Views: 1252

Answers (1)

Lars Anundskås
Lars Anundskås

Reputation: 1355

Try this:

config.Routes.MapHttpRoute(
        name: "RootInformation", 
        routeTemplate: "", 
        defaults: new 
        {
             Controller = "Core", 
             Action = "GetInformation"
        }
 );

Upvotes: 4

Related Questions