我正在运行" Asp.net WebApi with EntityFramework Identity"和" MVC SPA"在单个应用程序中,一次运行一个,下面是我的代码Global.asax> Application_Start给出了启动配置。
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configure(ODataConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
首先调用哪个路由注册只能访问应用程序,在上面的序列中只能访问WebAp,如果我更改序列并首先调用Application route,则只运行默认Web应用程序。
任何帮助将不胜感激。
如果您需要有关此的更多信息,请与我们联系。
提前感谢!!
修改
下面给出了所有配置。
RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
WebApiConfig:
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
ODataConfig:
public static void Register(HttpConfiguration config)
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Entities.Models.ListaValore>(typeof(Entities.Models.ListaValore).Name);
var model = builder.GetEdmModel();
config.Routes.MapODataRoute("odata", "odata", model);
config.EnableQuerySupport();
}