您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->IFNuke(修改自DNN)网站源码>>Library/Web/UrlRewriteModuleBAK.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:IFNuke(修改自DNN)网站源码
当前文件:文件类型 IFNuke/Library/Web/UrlRewriteModuleBAK.cs打开代码结构图
普通视图
		            
1//using System.Collections; 2//using System.Diagnostics; 3//using System; 4//using System.Text.RegularExpressions; 5//using System.Web; 6 7//using IFNuke; 8//using IFNuke.Data; 9//using IFNuke.BO; 10//using IFNuke.Web; 11//using IFNuke.Web.UI; 12 13//namespace IFNuke.Web.HttpModules 14//{ 15// public class UrlRewriteModuleBAK : IHttpModule 16// { 17// private void RewriteUrl(HttpApplication app) 18// { 19// Initialize.Init(app); 20 21// HttpRequest Request = app.Request; 22// HttpResponse Response = app.Response; 23// string requestedPath = app.Request.Url.AbsoluteUri; 24 25// // save original url in context 26// app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri); 27 28// // Friendly URLs are exposed externally using the following format 29// // http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx 30// // and processed internally using the following format 31// // http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx 32// // The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config 33// string sendTo = string.Empty; 34 35// // save and remove the querystring as it gets added back on later 36// // path parameter specifications will take precedence over querystring parameters 37// string queryString = string.Empty; 38// if (Request.Url.Query != string.Empty) 39// { 40// queryString = Request.QueryString.ToString(); 41// requestedPath = requestedPath.Replace(app.Request.Url.Query, ""); 42// } 43 44// int portalId = -1; 45// int tabId = -1; 46// string domanName = string.Empty; 47// string url = Request.Url.Host + Request.Url.LocalPath; 48// string[] splitUrl = url.Split('/'); 49 50// string alias = Request.Url.Host + Request.ApplicationPath; 51// if (splitUrl.Length > 0) 52// { 53// // get portalid 54// //for (int i = 0; i < splitUrl.Length; i++) 55// //{ 56// // if (alias == string.Empty) 57// // alias = splitUrl[i]; 58// // else 59// // alias = alias + "/" + splitUrl[i]; 60// // portalId = Globals.GetPortalIdByAlias(alias); 61// // if (portalId > 0) break; 62// //} 63 64// portalId = Globals.GetPortalIdByAlias(alias); 65 66// // get tabid 67// for (int i = 0; i < splitUrl.Length; i++) 68// { 69// if (splitUrl[i].ToLower() == "tabid") 70// { 71// tabId = int.Parse(splitUrl[i + 1]); 72// break; 73// } 74// } 75// } 76 77// // if no tabid, then use the portal's first tabid 78// if (tabId == -1) 79// { 80// tabId = Portal.GetDefaultTabId(portalId); 81// } 82 83// sendTo = Request.ApplicationPath + "/" + Globals.glbDefaultPage + "?portalid=" + portalId.ToString() + "&tabid=" + tabId.ToString(); 84// if (queryString != string.Empty) sendTo += "&" + queryString; 85 86// //Response.Redirect(sendTo); 87// app.Context.RewritePath(sendTo); 88// } 89 90// public void Init(HttpApplication application) 91// { 92 93// application.BeginRequest += new System.EventHandler(this.OnBeginRequest); 94 95// } 96 97// public void OnBeginRequest(object sender, EventArgs e) 98// { 99 100// HttpApplication app = (HttpApplication)sender; 101// HttpServerUtility Server = app.Server; 102// HttpRequest Request = app.Request; 103// HttpResponse Response = app.Response; 104// string requestedPath = app.Request.Url.AbsoluteUri; 105 106// //Carry out first time initialization tasks 107// ///Initialize.Init(app); 108 109// //exit if a request for a .net mapping that isn't a content page is made i.e. axd 110// //if (Request.Url.LocalPath.ToLower().EndsWith(".aspx") == false && Request.Url.LocalPath.ToLower().EndsWith(".asmx") == false && Request.Url.LocalPath.ToLower().EndsWith(".ashx") == false) 111// //{ 112// // return; 113// //} 114 115// // URL validation 116// // check for ".." escape characters commonly used by hackers to traverse the folder tree on the server 117// // the application should always use the exact relative location of the resource it is requesting 118// //string strURL = Request.Url.AbsolutePath; 119// //string strDoubleDecodeURL = Server.UrlDecode(Server.UrlDecode(Request.RawUrl)); 120// //if (Regex.Match(strURL, "[\\\\/]\\.\\.[\\\\/]").Success || Regex.Match(strDoubleDecodeURL, "[\\\\/]\\.\\.[\\\\/]").Success) 121// //{ 122// // throw (new HttpException(404, "Not Found")); 123// //} 124// //try 125// //{ 126// // //fix for ASP.NET canonicalization issues http://support.microsoft.com/?kbid=887459 127// // if (Request.Path.IndexOf('\u005C') >= 0 || System.IO.Path.GetFullPath(Request.PhysicalPath) != Request.PhysicalPath) 128// // { 129// // throw (new HttpException(404, "Not Found")); 130// // } 131// //} 132// //catch (Exception) 133// //{ 134// // //DNN 5479 135// // //request.physicalPath throws an exception when the path of the request exceeds 248 chars. 136// // //example to test: http://localhost/dotnetnuke_2/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/default.aspx 137// //} 138 139// //check if we are upgrading/installing or if this is a captcha request 140// //if (Request.Url.LocalPath.ToLower().EndsWith("install.aspx") || Request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx") || Request.Url.LocalPath.ToLower().EndsWith("captcha.aspx")) 141// //{ 142// // return; 143// //} 144 145// RewriteUrl(app); 146 147// // *Note: from this point on we are dealing with a "standard" querystring ( ie. http://www.domain.com/default.aspx?tabid=## ) 148 149// int portalId = int.Parse(Request.QueryString["portalid"]); 150// int tabId = int.Parse(Request.QueryString["tabid"]); 151 152// Portal p = new Portal(portalId, tabId); 153// app.Context.Items.Add("PortalSetting", p); 154// } 155 156// public void Dispose() 157// { 158// } 159 160// } 161 162//} 163 164
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:IFNuke(修改自DNN)网站源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号