首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

Global.asax 中做了伪静态, 怎么配置IIS服务器

2013-08-24 
Global.asax 中做了伪静态, 如何配置IIS服务器void Application_BeginRequest(object sender, EventArgs e

Global.asax 中做了伪静态, 如何配置IIS服务器


void Application_BeginRequest(object sender, EventArgs e)
    {
        
        HttpContext context = ((HttpApplication)sender).Context;

        string requestPath = context.Request.Path.ToLower();
        string requestPath2 = requestPath.Replace("/", "");
        requestPath2 = requestPath2.Replace(".html", "");
        if ( bz_ui_utils.GetClassByURL(requestPath2) != string.Empty )
        {
            Context.RewritePath("~/infolist.aspx?curl=" + requestPath2);
        }
        switch (requestPath)
        {
            case "/index.html":
                Context.RewritePath("~/index.aspx");
                break;
            case "/price.html":
                Context.RewritePath("~/price.aspx");
                break;
            case "/next2.html":
                Context.RewritePath("~/next2.aspx");
                break;
            case "/next3.html":
                Context.RewritePath("~/next3.aspx");
                break;
        }

        string pattern = string.Format(@"/(.*)_show_info_id_([\d]+).html$");
        if (Regex.IsMatch(requestPath, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
        {


            string newUrl = Regex.Replace(requestPath, pattern, "~/showinfos.aspx?curl=$1&iid=$2", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            Context.RewritePath(newUrl);
        }else{
            pattern = string.Format(@"/(.*)_([\d]+).html$");
            if (Regex.IsMatch(requestPath, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
            {
                string newUrl = Regex.Replace(requestPath, pattern, "~/infolist.aspx?curl=$1&page=$2", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                Context.RewritePath(newUrl);
            }else{
                pattern = string.Format(@"/search_q_(.*).html$");
                if (Regex.IsMatch(requestPath, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
                {
                    string newUrl = Regex.Replace(requestPath, pattern, "~/search.aspx?keyword=$1", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                    Context.RewritePath(newUrl);
                }
            }
        }
        pattern = string.Format(@"/search_q_(.*)_([\d]+).html$");
        if (Regex.IsMatch(requestPath, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
        {
            string newUrl = Regex.Replace(requestPath, pattern, "~/search.aspx?keyword=$1&page=$2", RegexOptions.IgnoreCase | RegexOptions.Compiled);


            Context.RewritePath(newUrl);
        }

    }



小弟在 Global.asax 中做了伪静态, 如何配置IIS服务器呀  IIS 7.0   访问html都是404错误 
请各位大侠出手帮忙!
[解决办法]
我是写在httpmoudle里面的
[解决办法]
跟你的一摸一样。
[解决办法]
iis 里设置指向html
[解决办法]
IIS 需要配置一下 .html文件应用程序映射

热点排行