public virtual IHtmlString Render(Page_Context pageContext, string positionId, string defaultHost, string defaultRequestPath, bool noProxy, CacheSettings cacheSetting) { string moduleURL = pageContext.PageRequestContext.ModuleUrlContext.GetModuleUrl(positionId); if (!string.IsNullOrEmpty(moduleURL)) { defaultRequestPath = moduleURL.Trim('~'); } var httpMethod = pageContext.ControllerContext.HttpContext.Request.HttpMethod; if (!defaultHost.StartsWith("http://")) { defaultHost = "http://" + defaultHost; } var requestUrl = UrlUtility.Combine(defaultHost, defaultRequestPath); Func <IHtmlString> getHtml = () => { Func <string, bool, string> proxyUrl = null; if (!noProxy) { proxyUrl = (url, isForm) => GenerateProxyUrl(pageContext, positionId, url, isForm); } if (httpMethod.ToUpper() == "POST") { var postModule = pageContext.PageRequestContext.AllQueryString[Kooboo.CMS.Sites.View.ModuleUrlContext.PostModuleParameter]; if (postModule != positionId) { httpMethod = "GET"; } } var html = _webProxy.ProcessRequest(pageContext.ControllerContext.HttpContext, requestUrl, httpMethod, proxyUrl); return(html); }; if (cacheSetting != null && cacheSetting.EnableCaching != null && cacheSetting.EnableCaching == true && httpMethod.ToUpper() == "GET") { string cacheKey = string.Format("{0}-{1}-{2}", positionId, requestUrl, noProxy); return(pageContext.PageRequestContext.Site.ObjectCache().GetCache(cacheKey, getHtml, cacheSetting.ToCachePolicy())); } else { return(getHtml()); } }
public virtual IHtmlString Render(ProxyRenderContext proxyRenderContext) { var positionId = proxyRenderContext.ProxyPosition.PagePositionId; Func <IHtmlString> getHtml = () => { var html = _webProxy.ProcessRequest(proxyRenderContext); return(html); }; var cacheSetting = proxyRenderContext.ProxyPosition.OutputCache; if (cacheSetting != null && cacheSetting.EnableCaching != null && cacheSetting.EnableCaching == true && proxyRenderContext.HttpMethod.ToUpper() == "GET") { string cacheKey = string.Format("{0}||{1}||{2}", positionId, proxyRenderContext.RequestUri.ToString(), proxyRenderContext.ProxyPosition.NoProxy); return(proxyRenderContext.PageRequestContext.Site.ObjectCache().GetCache(cacheKey, getHtml, cacheSetting.ToCachePolicy())); } else { return(getHtml()); } }