⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modulerewriter.cs

📁 1、用SQL查询器打开install目录下的dooogo.sql运行之后创建数据库dooogo。 2、然后打开web.config修改 <DbProvider type="Club.Fram
💻 CS
字号:
using System;
using System.Text.RegularExpressions;
using System.Configuration;
using Club.Common.URLRewriter.Config;

namespace Club.Common.URLRewriter
{
	/// <summary>
	/// Provides a rewriting HttpModule.
	/// </summary>
	public class ModuleRewriter : BaseModuleRewriter
	{
		/// <summary>
		/// This method is called during the module's BeginRequest event.
		/// </summary>
		/// <param name="requestedRawUrl">The RawUrl being requested (includes path and querystring).</param>
		/// <param name="app">The HttpApplication instance.</param>
		protected override void Rewrite(string requestedPath, System.Web.HttpApplication app)
		{
			// log information to the Trace object.
			app.Context.Trace.Write("ModuleRewriter", "Entering ModuleRewriter");

			// get the configuration rules
			RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

			// iterate through each rule...
			for(int i = 0; i < rules.Count; i++)
			{
				// get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory)
				string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$";

				// Create a regex (note that IgnoreCase is set...)
				Regex re = new Regex(lookFor, RegexOptions.IgnoreCase);

				// See if a match is found
				if (re.IsMatch(requestedPath))
				{
					// match found - do any replacement needed
					string sendToUrl = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, re.Replace(requestedPath, rules[i].SendTo));

					// log rewriting information to the Trace object
					app.Context.Trace.Write("ModuleRewriter", "Rewriting URL to " + sendToUrl);

					// Rewrite the URL
					RewriterUtils.RewriteUrl(app.Context, sendToUrl);
					break;		// exit the for loop
				}
			}

			// Log information to the Trace object
			app.Context.Trace.Write("ModuleRewriter", "Exiting ModuleRewriter");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -