何时使用路由与重写规则? [英] When to use routes vs. rewrite rules?

查看:176
本文介绍了何时使用路由与重写规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调试与路由问题,我刚刚意识到,MVC路线做极其类似的事情URL重写,但我没有很好地了解其情况的呼叫路由和呼叫URL重写。有人可以请解释一下其中,这两种技术的不同以及哪些情况下每个比较合适?

I'm trying to debug a problem with routing and I've just realized that MVC routes do something extremely similar to url rewriting but I don't have a good understanding of which situations call for routing and which call for url rewriting. Can someone please explain where these two technologies differ and for which situations each is appropriate?

推荐答案

URL重写分析请求的URL,并将其更改为同一服务器上的不同的URL。 URL重写模块在请求处理管道运行初期, Web服务器之前修改请求的URL处理程序决定使用哪个的处理请求。

Url Rewriting analyzes the requested URL and changes it to a different URL on the same server. The URL rewriting module runs early in the request-processing pipeline, modifying the requested URL before the Web server decides which handler to use to process the request.

路由是的请求调度机制的发生的之后的URL重写。当一个请求到Web服务器做ASP.NET路由查找在注册的路由列表请求的URL路径。如果找到的路线,该路线对应的处理程序被调用来处理该请求。

Routing is a request-dispatching mechanism that occurs after Url Rewriting. When a request is made to a Web server ASP.NET routing looks up the requested URL path in the list of registered routes. If the route is found, the corresponding handler for that route is invoked to process that request.

当你正在开发一个新应用程序或保持现有的使用途径。如果要在不改变内部它修补遗留应用程序使用URL重写。

Use routes when you are developing a new application or maintaining an existing one. Use Url rewriting when you want to patch a legacy application without changing it internally.

http://www.iis.net/learn/extensions/url-rewrite-module/iis-url-rewriting-and-aspnet-routing

这篇关于何时使用路由与重写规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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