/
Global.asax.cs
40 lines (36 loc) · 1.54 KB
/
Global.asax.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace LegacyApi
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
private void Application_PostResolveRequestCache(object sender, EventArgs e)
{
// Here we're going to decide which routes map to ASP.NET Core and which ones map to ASP.NET
// - /api/weather/ to ASP.NET Core
// - /api/values to ASP.NET
// At this point we've set the handler to take this request, now if this route maps to one
// we want to redirect to ASP.NET Core, so set the handler to null
if (Context.Request.Path.StartsWith("/api/weather", StringComparison.OrdinalIgnoreCase) ||
Context.Request.Path.StartsWith("/WebForm1.aspx", StringComparison.OrdinalIgnoreCase) ||
Context.Request.Path.StartsWith("/css", StringComparison.OrdinalIgnoreCase))
{
// Set a server variable pass state to the ASP.NET Core module
Context.Request.ServerVariables["FromFramework"] = "ASP.NET";
Context.RemapHandler(null);
}
}
}
}