-
Notifications
You must be signed in to change notification settings - Fork 54
Configure rest services
Scott Xu edited this page Aug 9, 2015
·
6 revisions
Rest services can either by configured using svc files and configure it in the web.config or you can add the routes manually in the global.asax
For the later add a RegisterRoutes method to the global.asax like this:
private void RegisterRoutes()
{
// We replace WebServiceHostFactory with NinjectWebServiceHostFactory so Ninject can handle creation of
// the services using the Ninjection kernel for each inbound request.
// RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
RouteTable.Routes.Add(new ServiceRoute("Service1", new NinjectWebServiceHostFactory(), typeof(Service1)));
}
If you derive from NinjectHttpApplication then call this method like this:
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
RegisterRoutes();
}
If you use App_Start to configure Ninject then call it like this:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}