public virtual string RenderBody() { velocityContext.Put("account", AccountCard); velocityContext.Put("header", renderHeader.ToString()); velocityContext.Put("buffer", renderBuffer.ToString()); velocityContext.Put("footer", renderFooter.ToString()); // 系统名称 velocityContext.Put("systemName", KernelConfigurationView.Instance.SystemName); // 系统状态 velocityContext.Put("systemStatus", KernelConfigurationView.Instance.SystemStatus); // 版本 velocityContext.Put("version", KernelConfigurationView.Instance.Version); // 默认域名 velocityContext.Put("domain", KernelConfigurationView.Instance.Domain); // 身份标识名称 velocityContext.Put("identityName", KernelContext.Current.AuthenticationManagement.IdentityName); // 页面加载次数 velocityContext.Put("reloadCount", this.reloadCount); // 给Session对象赋值,固定取得SessionID HttpContext.Current.Session["__session__ticket__"] = this.initializedTime; // 会话标识 velocityContext.Put("session", HttpContext.Current.Session.SessionID); // 时间间隔 velocityContext.Put("timeSpan", DateHelper.GetTimeSpan(this.initializedTime)); // ------------------------------------------------------- // 生成签名 // ------------------------------------------------------- velocityContext.Put("clientId", KernelConfigurationView.Instance.ApplicationClientId); // 时间戳 velocityContext.Put("timestamp", DateHelper.GetTimestamp()); // 随机数 velocityContext.Put("nonce", DigitalNumberContext.Generate("Key_Nonce")); // 签名 velocityContext.Put("clientSignature", Encrypter.EncryptSHA1(Encrypter.SortAndConcat( KernelConfigurationView.Instance.ApplicationClientSecret, velocityContext.Get("timestamp").ToString(), velocityContext.Get("nonce").ToString()))); return(VelocityManager.Instance.Merge(velocityContext, RenderBodyTemplatePath)); }
public void ProcessRequest(HttpContext context) { //context.Response.Write("1"); //IPage fac=(IPage)Assembly.Load("NewXzc.Web").CreateInstance("NewXzc.Web.Index",true); //fac.Page_Load(context); #region string physicalApplicationPath = context.Request.PhysicalApplicationPath; string str4 = context.Request.PhysicalPath.Replace(physicalApplicationPath, string.Empty).Replace("/", ".").Replace(@"\", ".").Replace(".aspx", string.Empty); string name = str4.Replace(".", "/") + ".html"; string str6 = string.Empty; //新添加测试 //if (str4.ToLower() == "default") //{ // HttpContext.Current.Response.Redirect("/index"); // return; //} //测试结束 if (str4.ToLower() == "index" || str4.ToLower() == "webscan_360_cn" || str4.ToLower() == "baidu_verify_kyltyss6um") { str6 = ""; } else { str6 = "template"; } if (str4.ToLower() == "tools.ueditor.dialogs.image.image") { str6 = ""; str4 = "image"; } else if (str4.ToLower() == "tools.ueditor.dialogs.link.link") { str6 = ""; str4 = "link"; } else if (str4.ToLower() == "tools.ueditor.dialogs.emotion.emotion") { str6 = ""; str4 = "emotion"; } else { str6 = "template"; } string str8 = "text/html"; string str9 = context.Request.ServerVariables["HTTP_ACCEPT"]; VelocityEngine engine = new VelocityEngine(); engine.SetProperty("resource.loader", "file"); engine.SetProperty("file.resource.loader.path", physicalApplicationPath + str6 + @"\"); engine.Init(); VelocityContext ctx = new VelocityContext(); string applicationPath = HttpContext.Current.Request.ApplicationPath; if (applicationPath == "/") { applicationPath = string.Empty; } #region 获取当前用户的登录状态 string url_s = HttpContext.Current.Request.Url.ToString().ToLower(); if (!url_s.Contains("hongrenhui")) { ctx.Put("headinfo", GetUserLoginState(1)); } else { ctx.Put("headinfo", GetUserLoginState(1)); } if (!url_s.Contains("userlogin")) { if (!url_s.Contains("hongrenhui")) { //当前用户还未登录 if (GetCurUserID_HongRenHui() == 0) { //进入中心页面,直接跳转回登录页 if (url_s.Contains("personalcenter")) { HttpContext.Current.Response.Redirect("/login"); } } } else { //当前用户还未登录 if (GetCurUserID_HongRenHui() == 0) { //进入中心页面,直接跳转回登录页 if (url_s.Contains("personalcenter")) { HttpContext.Current.Response.Redirect("/login"); } } } } #endregion ctx.Put("style", "/template/style"); ctx.Put("js", "/template/js"); ctx.Put("img", "/template/img"); ctx.Put("exname", ".aspx"); ctx.Put("showimg", NewXzc.Common.ImgHelper.GetCofigShowUrl()); IHandlerFactory factory = null; try { factory = (IHandlerFactory)Assembly.Load("NewXzc.Web").CreateInstance("NewXzc.Web.templatecs." + str4, true); if (factory == null) { //name = "/index"; name = "/404"; } else if (!(!(context.Request.HttpMethod == "POST"))) { factory.Page_PostBack(ref ctx); } else { factory.Page_Load(ref ctx); } } catch (Exception ex) { //context.Response.Redirect("/404"); context.Response.Write(ex.Message); } if (ctx.Get("redirecturl") != null) { string url = ctx.Get("redirecturl").ToString(); context.Response.Redirect(url); } try { Template template = engine.GetTemplate(name); StringWriter writer2 = new StringWriter(); template.Merge(ctx, writer2); context.Response.ContentType = str8; context.Response.Write(writer2.GetStringBuilder().ToString()); } catch (Exception ex) { context.Response.Write(ex.Message); } #endregion }