mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 23:42:33 +01:00
71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
using System;
|
|
using System.Data.Common;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.Web.Routing;
|
|
using NLog;
|
|
|
|
namespace NzbDrone.Services.Service
|
|
{
|
|
public class MvcApplication : HttpApplication
|
|
{
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
private static void RegisterRoutes(RouteCollection routes)
|
|
{
|
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
|
|
|
routes.MapRoute(
|
|
"Default", // Route name
|
|
"{controller}/{action}", // URL with parameters
|
|
new { controller = "Health", action = "Echo" } // Parameter default
|
|
);
|
|
|
|
}
|
|
|
|
private static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
|
{
|
|
filters.Add(new HandleErrorAttribute());
|
|
}
|
|
|
|
protected void Application_Start()
|
|
{
|
|
AreaRegistration.RegisterAllAreas();
|
|
|
|
RegisterGlobalFilters(GlobalFilters.Filters);
|
|
RegisterRoutes(RouteTable.Routes);
|
|
|
|
ViewEngines.Engines.Clear();
|
|
|
|
ModelBinders.Binders.DefaultBinder = new JsonModelBinder();
|
|
}
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
protected void Application_Error(object sender, EventArgs e)
|
|
{
|
|
var lastError = Server.GetLastError();
|
|
|
|
if (lastError is HttpException && lastError.InnerException == null)
|
|
{
|
|
logger.WarnException(String.Format("{0}. URL[{1}]", lastError.Message, Request.Path), lastError);
|
|
return;
|
|
}
|
|
|
|
logger.FatalException(lastError.Message + Environment.NewLine + Request.Url.PathAndQuery, lastError);
|
|
|
|
if (lastError is DbException)
|
|
{
|
|
logger.Warn("Restarting application");
|
|
HttpRuntime.UnloadAppDomain();
|
|
}
|
|
}
|
|
|
|
protected void Application_BeginRequest()
|
|
{
|
|
}
|
|
|
|
protected void Application_EndRequest()
|
|
{
|
|
}
|
|
}
|
|
} |