简体   繁体   English

在ASP.NET中重写网址?

[英]Url rewriting in asp.net?

i'm working on asp.net web application. 我正在处理asp.net Web应用程序。

please guide me for url rewriting in asp.net: 请指导我在asp.net中进行网址重写:

i need to change below link 我需要更改以下链接

http://www.faredepot.com/ViewArticle.aspx?aid=1

to

http://www.faredepot.com/Cheap_Flights_to_Atlanta.html

how can i achieve this i tried like following 我怎样才能做到这一点我尝试如下

void Application_BeginRequest(object sender, EventArgs e) {

        string fullOrigionalpath = Request.Url.ToString();

        if (fullOrigionalpath.Contains("http://www.faredepot.com/Cheap_Flights_to_Atlanta.html")) {
            Context.RewritePath("http://www.faredepot.com/ViewArticle.aspx?aid=1");
        }
    } 

or else trying to do it in web.config 否则尝试在web.config中执行此操作

<rewriter>
    <rewrite url="http://www.faredepot.com/ViewArticle.aspx?aid=1" to="http://www.faredepot.com/Cheap_Flights_to_Atlanta.htm" />
</rewriter>  

You have an excellent breakdown of all the possible solutions here: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx 您对这里所有可能的解决方案都有很好的了解: http : //weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

Which version of IIS are you using? 您正在使用哪个版本的IIS? For IIS7 use its own URL Rewrite Module, and for II6 use Intelligencia UrlRewriter.NET: http://urlrewriter.net/ 对于IIS7使用自己的URL重写模块,并使用II6 Intelligencia UrlRewriter.NET: http://urlrewriter.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM