使用 UrlRewriter.Net、ASP.NET MVC 路由进行 URL 重写或您推荐什么?
我只是想知道,如果您要在 ASP.NET 3.5 中创建新的 ASP.NET Web 表单应用程序,您会建议使用哪个 URL 重写? UrlRewriter.NET 或 ASP.NET MVC 路由。我以前使用过 UrlRewriter.NET 并且对它非常满意。
有人意见吗?
I'm just wondering, if you are creating a new ASP.NET web forms app in ASP.NET 3.5, which would you recommend for URL rewriting? UrlRewriter.NET or ASP.NET MVC Routing. I've used UrlRewriter.NET before and was pretty happy with it.
Opinions anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
恕我直言,路由要优越得多。你不是伪造它(重写 url 以让 SEO 类型满意),而是创造它(制作真实的 url 以让 SEO 类型满意)。另一个巨大的优点是路由是可逆的——你可以轻松地从参数中获取 URL,这非常方便。
不,他们做的事情截然不同。 url 重写获取传入的 url 并重写它,然后将请求传递给 ASP.NET(或 IIS)进行处理。 Url 路由采用 ASP.NET 中的 url,并使用 Url 中找到的参数映射处理程序。 URL 本身永远不会改变。
Routing is vastly superior IMHO. Rather than faking it (rewriting urls to keep the SEO types happy) you are making it (making real urls to keep the SEO types happy). The other huge advantage is that routing is reversable--you can easily get the URL from the parameters, which comes in very handy.
No, they do vastly different things. The url rewriting takes an incoming url and rewrites it before passing the request off to ASP.NET (or IIS) to handle. Url routing takes a url in ASP.NET and maps a handler using parameters found within the Url. The Url itself is never changed.
使用 UrlRewriter.NET - 它是为 Web 表单构建的,您已经有使用它的经验并且喜欢它。 ASP.NET MVC 路由设计为在 MVC 模式内工作。
Use UrlRewriter.NET - it was built for web forms and you already have experience with it and like it. ASP.NET MVC routing is designed to work within the MVC pattern.
如果您使用的是 IIS7,请使用 URL 重写模块< /a>.
我将它用于我的一个网站,效果非常好。
If you are using IIS7, go with the URL Rewrite Module.
I used it for one of my sites, and it worked perfectly.
为什么不直接使用 Asp.Net MVC 并完全放弃 Webform 方法呢?我意识到该框架并不适合所有人,特别是对于预先存在的项目,但如果您开始开发一个新应用程序并正在购买路由机制,为什么不选择基于该概念构建的框架呢?
Asp.Net MVC 是一个比 WebForms 更加优越的框架,它只需要更多的前期工作并且有一个学习曲线。但最终,您通常会得到一个更容易扩展和维护的应用程序。
Why not just go with Asp.Net MVC and ditch the webform methodology altogether? I realize that the framework isn't for everybody, especially for pre-existing projects, but if you are starting to develop a new app and are shopping for a routing mechanism, why not go for the framework that is built upon the notion?
Asp.Net MVC is a vastly superior framework over WebForms, it just requires a bit more upfront work and has a learning curve. At the end of the day though, you'll generally end up with an application that is much easier to expand and maintain.
ASP.NET 4.0 Web 表单(我相信它是在 3.5 SP1 中引入的)本身就内置了路由。与重写模块相比,它的优点是它本身构建在 ASP.NET 框架中,因此不需要修改即可正常工作。
所以你不应该仅仅因为路由而选择 MVC。
ASP.NET 4.0 web forms (I believe that it was introduced in 3.5 SP1) has routing build in natively. It has the benefit over rewriting modules that it is build in natively in the ASP.NET frameworks, and therefore does not need hacks to work correctly.
So you shouldn't go for MVC just because of the routing.