1
0
mirror of https://github.com/chyzy/RSystem-MVC synced 2024-11-29 08:55:27 +01:00
RSystem-MVC-Fork/RSystem/Global.asax.cs

51 lines
1.6 KiB
C#
Raw Normal View History

2018-04-17 11:20:49 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using AutoMapper;
using RSystem.Controllers;
using RSystem.Models;
using RSystem.ViewModels;
namespace RSystem
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
Mapper.Initialize(cfg => {
cfg.CreateMap<RecruitDataViewModel, RecruitData>();
cfg.CreateMap<RecruitData, RecruitDataViewModel>();
});
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
Response.Clear();
var httpexception = exception as HttpException;
var route = new RouteData();
route.Values.Add("controller","Error");
route.Values.Add("action","Index");
if(httpexception!=null)
route.Values.Add("id",httpexception.GetHttpCode().ToString());
Server.ClearError();
Response.TrySkipIisCustomErrors = true;
IController errorController=new ErrorController();
errorController.Execute(new RequestContext(new HttpContextWrapper(Context),route ));
}
}
}