初始化
This commit is contained in:
36
Face.Web/App_Start/BundleConfig.cs
Normal file
36
Face.Web/App_Start/BundleConfig.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Web;
|
||||
using System.Web.Optimization;
|
||||
|
||||
namespace Face.Web
|
||||
{
|
||||
public class BundleConfig
|
||||
{
|
||||
// 有关捆绑的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=301862
|
||||
public static void RegisterBundles(BundleCollection bundles)
|
||||
{
|
||||
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
|
||||
"~/Scripts/jquery-{version}.js"));
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
|
||||
"~/Scripts/jquery.validate*"));
|
||||
bundles.Add(new ScriptBundle("~/bundles/moviesScripts").Include(
|
||||
|
||||
/*"~/Scripts/jquery-{version}.js", use the previouse jquery in <head> section */
|
||||
"~/Scripts/jquery.validate*",
|
||||
"~/Scripts/modernizr-*",
|
||||
"~/Scripts/jquery.unobtrusive*"
|
||||
));
|
||||
// 使用要用于开发和学习的 Modernizr 的开发版本。然后,当你做好
|
||||
// 生产准备就绪,请使用 https://modernizr.com 上的生成工具仅选择所需的测试。
|
||||
//bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
|
||||
// "~/Scripts/modernizr-*"));
|
||||
|
||||
//bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
|
||||
// "~/Scripts/bootstrap.js"));
|
||||
|
||||
//bundles.Add(new StyleBundle("~/Content/css").Include(
|
||||
// "~/Content/bootstrap.css",
|
||||
// "~/Content/site.css"));
|
||||
}
|
||||
}
|
||||
}
|
||||
64
Face.Web/App_Start/FilterConfig.cs
Normal file
64
Face.Web/App_Start/FilterConfig.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Face.Web
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
||||
{
|
||||
filters.Add(new HandleErrorAttribute());
|
||||
filters.Add(new ExceptionAttribute());
|
||||
}
|
||||
}
|
||||
|
||||
public class ExceptionAttribute : FilterAttribute, IExceptionFilter
|
||||
{
|
||||
public virtual void OnException(ExceptionContext filterContext)
|
||||
{
|
||||
//记录日志
|
||||
//Face.Services.Manager.Logs.WriteErrorLog(filterContext.HttpContext.Request.Url.ToString(), filterContext.Exception);
|
||||
|
||||
if (!filterContext.ExceptionHandled)
|
||||
{
|
||||
string header = "";
|
||||
string ip = "本机线程";
|
||||
string url = "无地址,多线程执行";
|
||||
string Operationer = "未知";
|
||||
|
||||
//var loginInfo = Services.UserLoginHelper.CurrentUser();
|
||||
//if (loginInfo != null)
|
||||
//{
|
||||
// Operationer = string.Format("{0}", loginInfo.Uid);
|
||||
//}
|
||||
|
||||
if (filterContext.HttpContext.Request != null)
|
||||
{
|
||||
foreach (var item in filterContext.HttpContext.Request.Headers.AllKeys)
|
||||
{
|
||||
header += string.Format("{0}:{1},", item, filterContext.HttpContext.Request.Headers[item]);
|
||||
}
|
||||
|
||||
ip = Services.Tool.IPHelper.GetClientIp();
|
||||
url = filterContext.HttpContext.Request.Url.ToString();
|
||||
}
|
||||
|
||||
Log4Net.ExceptionLogHelper.Log(new Log4Net.ExceptionLogMessage()
|
||||
{
|
||||
ActionName = "渲染级别出错,路径:" + (string)filterContext.RouteData.Values["action"],
|
||||
exception = filterContext.Exception,
|
||||
Header = header,
|
||||
IP = ip,
|
||||
Url = url,
|
||||
Operationer = Operationer
|
||||
});
|
||||
//}
|
||||
|
||||
////转向
|
||||
//filterContext.ExceptionHandled = true;
|
||||
//filterContext.Result = new RedirectResult("~/Home/Error");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
21
Face.Web/App_Start/Handler/HandlerAuthorizeAttribute.cs
Normal file
21
Face.Web/App_Start/Handler/HandlerAuthorizeAttribute.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Face.Web
|
||||
{
|
||||
public class HandlerAuthorizeAttribute : ActionFilterAttribute
|
||||
{
|
||||
public bool Ignore { get; set; }
|
||||
public HandlerAuthorizeAttribute(bool ignore = true)
|
||||
{
|
||||
Ignore = ignore;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
24
Face.Web/App_Start/RouteConfig.cs
Normal file
24
Face.Web/App_Start/RouteConfig.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Face.Web
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Default",
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
|
||||
namespaces: new string[1] { "Face.Web.Controllers" }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Face.Web/App_Start/WebApiConfig.cs
Normal file
21
Face.Web/App_Start/WebApiConfig.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Face.Web
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user