asp.net

位置:IT落伍者 >> asp.net >> 浏览文章

ASP.NET中实现访问链接的静态地址映射


发布日期:2018年06月16日
 
ASP.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);

}

}

}

上一篇:在ASP.NET中为图像加入版权信息

下一篇:ASP.NET页面错误处理