您使用什么 Url 重写器进行 ASP.Net?[已结束]

What Url rewriter do you use for ASP.Net? [closed]

提问人:travis 提问时间:8/18/2008 最后编辑:Communitytravis 更新时间:8/25/2012 访问量:1620

问:

我查看了 ASP.Net 和 IIS 的几个 URL 重写器,想知道其他人使用什么,以及为什么。

以下是我使用过或看过的:

  • ThunderMain URLRewriter:在以前的项目中使用,没有我们想要的灵活性/性能
  • Ewal UrlMapper:在当前项目中使用,但源代码似乎被放弃了
  • UrlRewritingNet.UrlRewrite:似乎是一个不错的库,但文档糟糕的语法让我感到不安
  • UrlRewriter.NET:这是我目前的最爱,具有很大的灵活性,尽管注入替换正则表达式的额外函数稍微改变了标准的 .Net 正则表达式语法
  • 托管 Fusion URL 重写器:我在之前关于堆栈溢出的问题中找到了这个问题,但还没有尝试过,从示例语法来看,它似乎无法通过 web.config 进行编辑
asp.net IIS url 重写 urlrewriter

评论


答:

4赞 Keith 8/18/2008 #1

如果我现在开始一个新的 Web 项目,我会考虑从头开始使用 MVC。这使用重写的 URL 作为标准。

7赞 Mark Cidade 8/18/2008 #2

System.Web.Routing 刚刚随 .NET 3.5 一起发布。

您可以在自定义 HttpModule 中使用 Request.RewritePath()

我更喜欢使用 IHttpHandlerFactory 实现,并且可以完全控制所有传入 URL 及其映射到的位置。

2赞 Jason 8/18/2008 #3

我以前在流量非常高的网站上使用过 UrlRewriting.NET - 它对我们来说效果很好。我相信开发人员是德国人,所以英文文档可能没有想象的那么好。我强烈推荐它。

2赞 John Sheehan 8/19/2008 #4

我对 Ionic 的 ISAPI 重写过滤器有很好的体验,它与 ISAPI_Rewrite 非常相似,只是免费。两者都是以 mod_rewrite 为模型的,并且是 ISAPI 筛选器,因此无法在代码中管理它们,因为必须在 IIS 中设置它们。

3赞 Pat Hermens 8/20/2008 #5

+1 UrlRewritingNET.URLRewrite -- 在单个盒子上用于数百个服务/门户/站点,多年来没有问题!(@Jason——这就是你说的那个,对吧?

我也在个人网站上使用过这个 URLRewriter.NET,发现它很有趣。@travis,你对更改的语法是正确的,但一旦你习惯了它,它就很好。

评论

0赞 AlfeG 6/13/2009
我有问题。我需要的是重定向到另一个站点。例如: example.com/some3rdparty somesite.com/with?a lot&of&parameters 仅适用于微小的 URL 开箱即用是不可能的,需要对源进行更改。所以我使用了ManagedFusion
0赞 AlfeG 6/13/2009
此外,硬编码的部分名称“urlrewritingnet”是一个很大的惊喜T_T
0赞 Pat Hermens 7/2/2009
这并非不可能。它只需要奉献精神和定义。我想你在说下面这样的东西?<添加 virtualUrl=“^~/some3rdparty” rewriteUrlParameter=“ExcludeFromClientQueryString” destinationUrl=“somesite.com/with?a lot=$2&of=$3&parameters=$4.$5” ignoreCase=“true” /> 还是只添加 destinationUrl=“somesite.com/with?a lot&of&parameters”?当然,有一个学习曲线,但嘿,这是我用过的更全面的曲线之一。路由和 MVC 天生就是为了一起使用而生的,在这种情况下,它们肯定不会更好地帮助您。
1赞 chrisofspades 8/24/2008 #6

I just installed Helicon's ISAPI Rewrite 3. Works exactly like htaccess. I'm diggin it so far.

1赞 Dscoduc 1/7/2009 #7

I used .NET URL Rewriter and Reverse Proxy with great success. It's almost on par with mod_rewrite and uses almost all of the same syntax's. The owner of the project is extremely helpful and friendly and the product works great. This gem provides both Rewriting and Proxy functionality, which many solutions don't offer. IMO, worth a look.

3赞 notandy 2/27/2009 #8

IIS 7 has an URL Rewrite Module that is fairly capable and integrates well with IIS.

评论

0赞 BritishDeveloper 4/14/2010
+1 for being new skool! This is what I use. Be careful though if you're used to UrlRewritingNet.Rewrite, since Request.Url is now the actual page rather than the requested one. Now you need Request.RawUrl to get the url that was actually requested
2赞 aron 10/14/2009 #9

I would not recommend UrlRewritingNet if you are in an IIS7 Windows 2008 environment.

Reason: UrlRewritingNet requires that you app pool mode = Classic and NOT integrated. This is not optimal Also, their project seems very dead that last 2 years.

评论

0赞 balint 11/27/2013
it is not an issue on Windows 2008 R2, all sites (50+) running in integrated pools with UrlRewritingNet.UrlRewrite
0赞 Jonas T 5/26/2011 #10

+1 for UrlRewritingNet.UrlRewrite too but why do I always need to end my URL with .aspx? I think it should be improved better regular expression partern.

Why do I always have to end with aspx in virtualURL localhost/Products/Beverages.aspx", "localhost/Products/Condiments.aspx". I just want to type localhost/Products/Beverages", "localhost/Products/Condiments" which look like MVC route.

This one look good but it is not working for my site. I still can't figure it out.

评论

0赞 travis 5/26/2011
Ending with use to be due to a limitation with IIS. Otherwise you'd have to map to use the aspnet_isapi.dll. Many hosting providers don't allow that and it can lead to poorer performance and some other odd quirks, like PNGs being served with the wrong mime-type..aspx.*
0赞 Paras 8/25/2012 #11

asp.net routing serves the requirement of url rewriting as well and even much more than. With asp.net routing you can not just "rewrite the url" but create custom handlers for various requests. asp.net routing however requires at least asp.net sp1.

The basic thing that you do for a simple routing to work is add a few route handlers in the Application_Start even inside the Global.asax.cs file.

 protected void Application_Start(object sender, EventArgs e)
        {

                        RegisterRoutes(RouteTable.Routes);


        }
        private static void RegisterRoutes(RouteCollection routes)
        {          

            routes.Add("Routing1", new Route("/Blog/id/2","/Blog.aspx"));

        }