zoukankan      html  css  js  c++  java
  • 伪静态

    首先加类

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data;
    using System.Data.SqlClient;
    using Norco.DAL;

    /

        /// <summary>
        /// Summary description  for UrlRewriter
        /// </summary>
        public class SupportWJ : IHttpHandler
        {
            public SupportWJ()
            {
                //
                // TODO: Add constructor logic here
                //
            }
            public void ProcessRequest(HttpContext Context)
            {
                try
                {
                    //取得原始URL屏蔽掉参数
                    string Url = Context.Request.RawUrl;
                    //建立正则表达式
                    //string sql = "insert into test(TestName) values(@test)";
                    //SqlParameter tmp = new SqlParameter("@test", SqlDbType.NVarChar, 2500);
                    //tmp.Value = Url;

                    //DbAccess.SQLExecuteNoneQuery(sql, tmp);
                    System.Text.RegularExpressions.Regex Reg = new System.Text.RegularExpressions.Regex(@"/NORCO-Support-(\d+)\.shtml", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    //用正则表达式进行匹配
                    System.Text.RegularExpressions.Match m = Reg.Match(Url, Url.LastIndexOf("/NORCO-Support-"));//从最后一个“/”开始匹配

                    //String RealPath = @"/about.aspx?id=" + m.Groups[1];

                  

                    if (m.Success)//匹配成功
                    {
                        String RealPath = @"/Servers.aspx?sid=" + m.Groups[1];

                        //string sql = "insert into test(TestName) values(@test)";
                        //SqlParameter tmp = new SqlParameter("@test", SqlDbType.NVarChar, 50);
                        //tmp.Value = RealPath;


                        //DbAccess.SQLExecuteNoneQuery(sql, tmp);


                        //Context.Response.Write(RealPath);
                        //Context.RewritePath(RealPath);//(RewritePath 用在无 Cookie 会话状态中。)
                        Context.Server.Execute(RealPath);
                    }
                    else
                    {
                        Context.Response.Write("404 ERROR!");
                    }
                }
                catch
                {
                    Context.Response.Redirect(Context.Request.Url.ToString());
                }
            }
            /**/
            /// <summary>
            /// 实现“IHttpHandler”接口所必须的成员
            /// </summary>
            /// <value></value>
            /// Author:yoyo
            /// blog:http://yangmingsheng.cn
            public bool IsReusable
            {
                get { return false; }
            }

        }

    其次在web.config加

    <add verb="GET" path="*/NORCO-Support-*.shtml" type="SupportWJ"/>

    其次,配置加对shtml后缀的类ASPX处理

  • 相关阅读:
    基于 Android NDK 的学习之旅-----序言
    音乐播放时跳动的音符
    WebView中实现文件下载功能
    Android组件——使用DrawerLayout仿网易新闻v4.4侧滑菜单
    android webview中的音乐的暂停与播放
    Android 使用Fragment界面向下跳转并一级级返回
    Fragment使用LocalBroadcastManager接收广播消息
    android WebView总 结
    解决方式:QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
    Android学习十九:ContentProvider初步
  • 原文地址:https://www.cnblogs.com/tangself/p/1645061.html
Copyright © 2011-2022 走看看