MarkItUp.SingleUserBlog/UI/PostRequestModule.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Collections.Specialized;
using System.Globalization;
using System.Collections;
using MarkItUp.SingleUserBlog.Common;
using System.Text;
using System.Text.RegularExpressions;

namespace MarkItUp.SingleUserBlog.Web
{
/// <summary>
/// Matches urls agains a regex string and rewrites them
/// </summary>
/// 由liudao汉化,http://liudao.cnblogs.com
/// //该源码下载自www.51aspx.com(51aspx.com)

    public class PostRequestModule : System.Web.IHttpModule
    {
        public PostRequestModule()
        {

        }

        #region IHttpModule Members

        public void Dispose()
        {

        }

        public void Init(HttpApplication context)
        {
            context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
        }

        void context_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            Rewrite(app.Request.Path, app);
        }

        protected void Rewrite(string requestedPath,
         HttpApplication app)
        {
            string path = app.Context.Request.ServerVariables["SCRIPT_NAME"];
            NameValueCollection rules = ConfigurationManager.GetSection("RewriterConfig/RewriterRules") as NameValueCollection;
            foreach (string rule in rules.AllKeys)
            {
                string sendto = rules[rule];
                Regex ex = new Regex(rule, RegexOptions.IgnoreCase);
                if (ex.IsMatch(path))
                {
                    string newpath = ex.Replace(path, sendto);
                    string query = newpath.LastIndexOf("?") > -1 ? newpath.Substring(newpath.LastIndexOf("?") + 1) : "";
                    newpath = newpath.LastIndexOf("?") > -1 ? newpath.Remove(newpath.LastIndexOf("?")) : newpath;
                    app.Context.RewritePath(newpath, app.Context.Request.PathInfo, query);
后面还有 7 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。