Skip to content

Instantly share code, notes, and snippets.

@choudeshell
Last active December 12, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choudeshell/4703750 to your computer and use it in GitHub Desktop.
Save choudeshell/4703750 to your computer and use it in GitHub Desktop.
This XML file does not appear to have any style information associated with it. The document tree is shown below. <Error> <Message>An error has occurred.</Message> <ExceptionMessage> Multiple types were found that match the controller named 'Test'. This can happen if the route that services this request ('api/v1/hello') found multiple controller…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace MvcApplication1
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Controller: MvcApplication1.Controllers.V1.Test
config.Routes.MapHttpRoute(
name: "HelloV1",
routeTemplate: "api/v1/hello",
defaults: new { id = RouteParameter.Optional, controller = "Test", action = "Hello" }
);
// Controller: MvcApplication1.Controllers.V2.Test
config.Routes.MapHttpRoute(
name: "HelloV2",
routeTemplate: "api/v2/hello_v2",
defaults: new { id = RouteParameter.Optional, controller = "Test", action = "Hello_V2" }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment