Mineplex2018-withcommit/Website/LOC.Website.Web/Global.asax.cs

70 lines
2.3 KiB
C#
Raw Permalink Normal View History

2013-08-27 17:14:08 +02:00
namespace LOCWebsite
{
using LOC.Core;
using LOC.Core.DependencyResolution;
using LOC.Website.Common.Contexts;
using LOC.Website.Web;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using LOC.Website.Web.Areas.Manage;
// 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}");
routes.MapRoute(
"Profile", // Route name
"Profile/{name}", // URL with parameters
new {controller = "Profile", action = "Index", name = UrlParameter.Optional} // Parameter defaults
);
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);
ModelBinders.Binders.DefaultBinder = new JsonModelBinder();
UpdateJsonProvider();
var resolver = Resolver.Current;
var locDatabaseUpdater = new LOCDatabaseUpdater();
locDatabaseUpdater.Update();
}
private void UpdateJsonProvider()
{
// find the default JsonVAlueProviderFactory
JsonValueProviderFactory jsonValueProviderFactory = ValueProviderFactories.Factories.OfType<JsonValueProviderFactory>().FirstOrDefault();
// remove the default JsonVAlueProviderFactory)
if (jsonValueProviderFactory != null)
{
ValueProviderFactories.Factories.Remove(jsonValueProviderFactory);
}
// add the custom one
ValueProviderFactories.Factories.Add(new CustomJsonValueProviderFactory());
}
}
}