1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-11 13:32:42 +01:00
Radarr/NzbDrone.Web/Global.asax.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2010-10-15 09:10:44 +02:00
using System;
using System.Diagnostics;
using System.Threading;
2010-10-15 09:10:44 +02:00
using System.Web;
using System.Web.Mvc;
2010-09-23 05:19:47 +02:00
using System.Web.Routing;
using Ninject;
using Ninject.Web.Mvc;
2010-10-15 09:10:44 +02:00
using NLog;
2010-09-23 05:19:47 +02:00
using NzbDrone.Core;
using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
2010-09-23 05:19:47 +02:00
namespace NzbDrone.Web
{
public class MvcApplication : NinjectHttpApplication
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2010-09-23 05:19:47 +02:00
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*robotstxt}", new { robotstxt = @"(.*/)?robots.txt(/.*)?" });
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Series", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected override void OnApplicationStarted()
{
LogConfiguration.Setup();
Logger.Info("NZBDrone Starting up.");
CentralDispatch.DedicateToHost();
2010-09-23 05:19:47 +02:00
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
base.OnApplicationStarted();
2010-09-29 19:19:18 +02:00
}
2010-09-23 05:19:47 +02:00
protected override IKernel CreateKernel()
{
var kernel = CentralDispatch.NinjectKernel;
// kernel.Bind<IRepository>().ToConstant(kernel.Get<IRepository>("LogDb"));
return kernel;
2010-10-15 09:10:44 +02:00
}
2010-10-10 21:00:07 +02:00
2010-10-15 09:10:44 +02:00
// ReSharper disable InconsistentNaming
protected void Application_Error(object sender, EventArgs e)
{
var lastError = Server.GetLastError();
if (lastError is HttpException)
{
2010-10-24 19:35:58 +02:00
Logger.WarnException(lastError.Message, lastError);
}
else
{
2010-10-24 19:35:58 +02:00
Logger.FatalException(lastError.Message, lastError);
}
}
protected void Application_BeginRequest()
{
Thread.CurrentThread.Name = "UI";
2010-09-23 05:19:47 +02:00
}
2010-10-15 09:10:44 +02:00
2010-09-23 05:19:47 +02:00
}
}