熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET中實現訪問鏈接的靜態地址映射

2013-11-13 10:29:59  來源: .NET編程 

  protected void Application_BeginRequest(Object sender EventArgs e) {
       
        string strCurrentPath;
        strCurrentPath = RequestPath;
        //make sure that it ends with aspx  This is some quick validation on the path
        //This will shortcut processing for images and other files (WebResourceaxd for example)
        if(SystemIOPathGetExtension(strCurrentPath)EndsWith(
            aspx true SystemGlobalizationCultureInfoInvariantCulture)) {
            string strCustomPath;
            string qString = RequestQueryStringToString();
            if(qString != stringEmpty)
                qString = & + qString;
            strCurrentPath = strCurrentPathToLowerInvariant();
            string appRoot = GetAppRoot(strCurrentPath);
            //string pageName = ;
            // the URL contains this folder name
            //ResponseWrite(strCurrentPath);
            if(strCurrentPathIndexOf(catalog/ StringComparisonInvariantCultureIgnoreCase) > ) {

  appRoot = appRootReplace(catalog/ );
                strCustomPath = appRoot + catalogaspx?guid= + SystemIOPathGetFileNameWithoutExtension(strCurrentPath) + qString;

  // rewrite the URL
                ContextRewritePath(strCustomPath false);
            }
            else if(strCurrentPathIndexOf(product/ StringComparisonInvariantCultureIgnoreCase) > ) {
                appRoot = appRootReplace(product/ );

  strCustomPath = appRoot + productaspx?guid= + SystemIOPathGetFileNameWithoutExtension(strCurrentPath);
                // rewrite the URL

  ContextRewritePath(strCustomPath false);
            }
        }
    }


From:http://tw.wingwit.com/Article/program/net/201311/13825.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.