-
Notifications
You must be signed in to change notification settings - Fork 2
/
Global.asax.cs
73 lines (60 loc) · 2.22 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Web.Mvc;
using System.Web.Routing;
namespace Todo
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
var url = "api/Todos";
routes.MapRoute(
"Todo_GET",
url,
new { controller = "Home", action = "Get", area = "" },
new { httpMethod = new HttpMethodConstraint("GET") }
);
routes.MapRoute(
"Todo_GET_ONE",
url + "/{id}",
new { controller = "Home", action = "GetOne" },
new { httpMethod = new HttpMethodConstraint("GET") }
);
routes.MapRoute(
"Todo_POST",
url,
new { controller = "Home", action = "Post" },
new { httpMethod = new HttpMethodConstraint("POST") }
);
routes.MapRoute(
"Todo_PUT",
url + "/{id}",
new { controller = "Home", action = "Put" },
new { httpMethod = new HttpMethodConstraint("PUT") }
);
routes.MapRoute(
"Todo_DELETE",
url + "/{id}",
new { controller = "Home", action = "Delete" },
new { httpMethod = new HttpMethodConstraint("DELETE") }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
}