You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/NzbDrone.Web/Global.asax.cs

92 lines
2.8 KiB

using System;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
using System.Web;
using System.Web.Mvc;
14 years ago
using System.Web.Routing;
using Ninject;
using Ninject.Web.Mvc;
using NLog;
14 years ago
using NzbDrone.Core;
using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
14 years ago
namespace NzbDrone.Web
{
public class MvcApplication : NinjectHttpApplication
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
14 years ago
public static void RegisterRoutes(RouteCollection routes)
{
14 years ago
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*robotstxt}", new { robotstxt = @"(.*/)?robots.txt(/.*)?" });
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
14 years ago
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Series", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
14 years ago
}
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
LogConfiguration.Setup();
Logger.Info("NZBDrone Starting up.");
CentralDispatch.DedicateToHost();
14 years ago
RegisterRoutes(RouteTable.Routes);
//base.OnApplicationStarted();
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
//RegisterRoutes(RouteTable.Routes);
}
14 years ago
protected override IKernel CreateKernel()
{
var kernel = CentralDispatch.NinjectKernel;
// kernel.Bind<IRepository>().ToConstant(kernel.Get<IRepository>("LogDb"));
kernel.Load(Assembly.GetExecutingAssembly());
return kernel;
}
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
// ReSharper disable InconsistentNaming
protected void Application_Error(object sender, EventArgs e)
{
var lastError = Server.GetLastError();
if (lastError is HttpException)
{
14 years ago
Logger.WarnException(String.Format("{0}. URL[{1}]", lastError.Message, Request.Path), lastError);
if (Request.Path.EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase))
{
Response.Redirect(Request.ApplicationPath);
}
}
else
{
Logger.FatalException(lastError.Message, lastError);
}
}
protected void Application_BeginRequest()
{
Thread.CurrentThread.Name = "UI";
14 years ago
}
14 years ago
}
}