69 lines
2.5 KiB
C#
69 lines
2.5 KiB
C#
using System;
|
|
using System.Security.Principal;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using System.Web.Optimization;
|
|
using System.Web.Routing;
|
|
using System.Web.Security;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB
|
|
{
|
|
// 注意: 有关启用 IIS6 或 IIS7 经典模式的说明,
|
|
// 请访问 http://go.microsoft.com/?LinkId=9394801
|
|
|
|
public class MvcApplication : System.Web.HttpApplication
|
|
{
|
|
public MvcApplication()
|
|
{
|
|
AuthorizeRequest += new EventHandler(MvcApplication_AuthorizeRequest);
|
|
}
|
|
protected void Application_Start()
|
|
{
|
|
AreaRegistration.RegisterAllAreas();
|
|
|
|
ControllerBuilder.Current.SetControllerFactory(new WebHelper.Infrastructure.NinjectControllerFactory());
|
|
|
|
WebApiConfig.Register(GlobalConfiguration.Configuration);
|
|
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
|
|
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
|
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
|
RegisterView();//注册视图访问规则
|
|
|
|
if (!string.IsNullOrEmpty(Utility.GetSettingByKey("IsShare")))
|
|
{
|
|
var _shareName = Utility.GetSettingByKey("NetUseShareName") ?? @"\\192.168.1.171\weixin";
|
|
var user = Utility.GetSettingByKey("NetUseUser") ?? @"192.168.1.171\admin";
|
|
var pwd = Utility.GetSettingByKey("NetUsePwd") ?? "read,./1";
|
|
NetUseHelper.Build(_shareName, user, pwd, string.Empty);//不指定盘符,避免引起盘符被占用的错误
|
|
}
|
|
|
|
}
|
|
protected void RegisterView()
|
|
{
|
|
ViewEngines.Engines.Clear();
|
|
ViewEngines.Engines.Add(new MyViewEngineConfig());
|
|
}
|
|
void MvcApplication_AuthorizeRequest(object sender, EventArgs e)
|
|
{
|
|
var id = Context.User.Identity as FormsIdentity;
|
|
if (id != null && id.IsAuthenticated)
|
|
{
|
|
string[] roles = UserRightsHelper.getUserRights();
|
|
|
|
Context.User = new GenericPrincipal(id, roles);
|
|
}
|
|
}
|
|
|
|
//protected void Application_PostAuthenticateRequest(object sender, EventArgs e) {
|
|
// var id = Context.User.Identity as FormsIdentity;
|
|
// if (id != null && id.IsAuthenticated)
|
|
// {
|
|
// string[] roles = UserInfoHelper.userRightId;
|
|
|
|
// Context.User = new GenericPrincipal(id, roles);
|
|
// }
|
|
//}
|
|
}
|
|
} |