ASP.NET,IIS 6和URL重写 [英] ASP.NET, IIS 6 and url rewriting

查看:156
本文介绍了ASP.NET,IIS 6和URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我买一个托管在Windows主机供应商与IIS 6共享

i've bought a shared hosting on a windows hoster with IIS 6.

我想知道如何重写URL。

I would like to know how to rewrite url.

我不能在服务器上修改什么,我能做的唯一的事情就是用...我的asp.net code!
一些忠告 ?

I can't modify anything on the server, the only thing i can do is to use ... my asp.net code ! some advice ?

谢谢!

推荐答案

由于ScottGu博客建议,你可以

As the ScottGu blog suggests, you can

1。做重写使用ASP.NET提供

void Application_BeginRequest(object sender, EventArgs e) {

    string fullOrigionalpath = Request.Url.ToString();

    if (fullOrigionalpath.Contains("/Products/Books.aspx")) {
        Context.RewritePath("/Products.aspx?Category=Books");
    }
    else if (fullOrigionalpath.Contains("/Products/DVDs.aspx")) {
        Context.RewritePath("/Products.aspx?Category=DVDs");
    }
} 

2。使用HTTP模块结果
使用的HttpModule (如 urlrewriter.net )不需要服务器上的任何变化,只在的Web.Config 和部署模块的DLL

2. Use a HttpModule
Using a HttpModule (such as urlrewriter.net) does not require any changes on the server, only some changes on Web.Config and deploying the module DLLs

这篇关于ASP.NET,IIS 6和URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆