日期:2014-05-17 浏览次数:20437 次
using System.Web.Mvc;
namespace Info.Areas.Api
{
public class ApiAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Api";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Api_default",
"Api/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new string[] {"Info.Areas.Api.Controllers"}
);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace Info
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}