Пример #1
0
        private void ConfigureHttpConfiguration(IAppBuilder app)
        {
            var configuration = _WebAppConfiguration.GetHttpConfiguration();

            configuration.MapHttpAttributeRoutes();
            configuration.Routes.MapHttpRoute(
                name:           "DefaultApi",
                routeTemplate:  "api/{controller}/{id}",
                defaults:       new { id = RouteParameter.Optional }
                );

            var basicAuthenticationWebApiHandler = (System.Net.Http.DelegatingHandler)Factory.Resolve <IBasicAuthenticationWebApiMessageHandler>();

            configuration.MessageHandlers.Add(basicAuthenticationWebApiHandler);

            configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(
                new RequestHeaderMapping(
                    "Accept",
                    "text/html",
                    StringComparison.OrdinalIgnoreCase,
                    true,
                    "application/json"
                    )
                );
        }
Пример #2
0
        private void ConfigureHttpConfiguration(IAppBuilder app)
        {
            var configuration = _WebAppConfiguration.GetHttpConfiguration();

            configuration.MapHttpAttributeRoutes();
            configuration.Routes.MapHttpRoute(
                name:           "DefaultApi",
                routeTemplate:  "api/{controller}/{id}",
                defaults:       new { id = RouteParameter.Optional }
                );
        }
Пример #3
0
 public void WebAppConfiguration_GetHttpConfiguration_Returns_Null_If_Configure_Has_Never_Been_Called()
 {
     Assert.IsNull(_Configuration.GetHttpConfiguration());
 }