zoukankan      html  css  js  c++  java
  • 转:Global.asax通过Application_BeginRequest()事件实现访问链接的静态地址映射

    protected void Application_BeginRequest(Object sender, EventArgs e) {
            
            
    string strCurrentPath;
            strCurrentPath 
    = Request.Path;
            
    //make sure that it ends with aspx.  This is some quick validation on the path. 
            
    //This will shortcut processing for images and other files (WebResource.axd, for example). 
            if(System.IO.Path.GetExtension(strCurrentPath).EndsWith(
                
    "aspx"true, System.Globalization.CultureInfo.InvariantCulture)) {
                
    string strCustomPath;
                
    string qString = Request.QueryString.ToString();
                
    if(qString != string.Empty)
                    qString 
    = "&" + qString;
                strCurrentPath 
    = strCurrentPath.ToLowerInvariant();
                
    string appRoot = GetAppRoot(strCurrentPath);
                
    //string pageName = "";
                
    // the URL contains this folder name
                
    //Response.Write(strCurrentPath);
                if(strCurrentPath.IndexOf("catalog/", StringComparison.InvariantCultureIgnoreCase) > -1) {

                    appRoot 
    = appRoot.Replace("catalog/""");
                    strCustomPath 
    = appRoot + "catalog.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath) + qString;

                    
    // rewrite the URL
                    Context.RewritePath(strCustomPath, false);
                }
                
    else if(strCurrentPath.IndexOf("product/", StringComparison.InvariantCultureIgnoreCase) > -1) {
                    appRoot 
    = appRoot.Replace("product/""");

                    strCustomPath 
    = appRoot + "product.aspx?guid=" + System.IO.Path.GetFileNameWithoutExtension(strCurrentPath);
                    
    // rewrite the URL

                    Context.RewritePath(strCustomPath, 
    false);
                }
            }
        }

    文章来自学IT网:http:
    //www.xueit.com/html/2009-03/21_774_00.html
  • 相关阅读:
    腾讯视频插入网页的代码;
    FW: 软件持续交付的诉求;
    TOGAF
    Windows WSL2 htop打开黑屏的问题解决
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='appts.xxx.com%20', port=443):
    sqlalchemy实现模糊查询
    jenkins过滤版本,可选择版本
    QML 布局之一:锚布局详解(各种例子)
    Qt Quick 常用控件:Button(按钮)用法及自定义
    The Common Order Operations of Dis Operation System (DOSS)
  • 原文地址:https://www.cnblogs.com/wantingqiang/p/1574583.html
Copyright © 2011-2022 走看看