Beispiel #1
0
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "HelpPage_Default",
                "Help/{action}/{apiId}",
                new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

            HelpPageConfig.Register(GlobalConfiguration.Configuration);
        }
        /// <summary>
        /// Called when the application is started. Calls all of the registration methods required by
        /// the application and sets global configuration properties.
        /// </summary>
        protected override void OnApplicationStarted()
        {
            // Set admin role from web.config
            adminRole = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["AdminRole"]) ?
                        ConfigurationManager.AppSettings["AdminRole"] : "";

            // Only use the razor view engine
            System.Web.Mvc.ViewEngines.Engines.Clear();
            System.Web.Mvc.ViewEngines.Engines.Add(new ThemableRazorViewEngine());

            // Resolve assemblies that fail to load
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;

            // Register default stuff as well as any additional filters/routes required by the implementing application
            RegisterGlobalFilters(GlobalFilters.Filters);

            // Register all non-WCF routes
            RegisterRoutes(RouteTable.Routes);

            // Register WCF routes
            RegisterServiceRoutes();

            //// Help page registration
            HelpPageConfig.Register(GlobalConfiguration.Configuration);

            // Register a final global 404 not found route
            RouteTable.Routes.MapRoute("NotFound", "{*url}",
                                       new { controller = "Error", action = "Http404" },
                                       new[] { "Geocrest.Web.Mvc.Controllers" });

            // Bundles for javascript/css minification
            RegisterBundles(BundleTable.Bundles);

            // Add enrichers for HAL
            GlobalConfiguration.Configuration.MessageHandlers.Add(new EnrichingHandler());

            // Add formatters
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings
            {
                Formatting = Newtonsoft.Json.Formatting.Indented,
                //NullValueHandling = NullValueHandling.Ignore,
                DefaultValueHandling = DefaultValueHandling.Include,
            };
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.AddQueryStringMapping(BaseApplication.FormatParameter, "json", "application/json");
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.AddQueryStringMapping(BaseApplication.FormatParameter, "xml", "application/xml");
            GlobalConfiguration.Configuration.Formatters.Add(new PlainTextFormatter());
            GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Default;

            // Ensure ASP.NET Simple Membership is initialized only once per app start
            if (IsSimpleMembershipProviderConfigured())
            {
                System.Threading.LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
            }
        }
 /// <summary>
 /// Registers core routes such as ignore routes and help page routes as well as any
 /// additional routes required by the application.
 /// <para>The following routes have been ignored within this method:
 /// <list type="bullet">
 /// <item>content/*</item>
 /// <item>scripts/*</item>
 /// <item>views/*</item>
 /// <item>{resource}.axd/{*pathInfo}</item>
 /// <item>{*favicon}</item>
 /// <item>{*allsvc}</item>
 /// </list></para>
 /// </summary>
 /// <param name="routes">The global route collection.</param>
 protected virtual void RegisterRoutes(RouteCollection routes)
 {
     routes.IgnoreRoute("{resource}.css/{*pathInfo}");
     routes.IgnoreRoute("{resource}.js/{*pathInfo}");
     routes.IgnoreRoute("{resource}.jpg/{*pathInfo}");
     routes.IgnoreRoute("content/*");
     routes.IgnoreRoute("scripts/*");
     routes.IgnoreRoute("views/*");
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
     routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
     routes.IgnoreRoute("{*allsvc}", new { allsvc = @".*\.svc(/.*)?" });
     HelpPageConfig.RegisterRoutes(routes);
     RegisterAreas();
 }