IIS URL Rewriting and ASP.NET Routing
IIS URL Rewriting and ASP.NET Routing
With the release of the URL Rewrite Module for IIS and the inclusion of ASP.NET routing into the .NET Framework 4, there have been a lot of questions from ASP.NET developers about how these two features relate to each other and when you should use one or the other. This document describes the differences between these two technologies and provides guidance for Web developers about when to use IIS URL rewriting and when to use ASP.NET routing.
From a high-level perspective, it seems like these technologies provide very similar functionality--both allow your Web applications to have user-friendly and search-engine-friendly URLs.
However, there are fundamental differences between these two technologies that are important to understand to make the right decision about what to use for your Web application.
To help you understand those differences, we will first explain how IIS URL rewriting and ASP.NET routing work.
Differences Between IIS URL Rewriting and ASP.NET Routing
Based on the above explanation, there are the following main conceptual differences between IIS URL rewriting and ASP.NET routing:
- URL rewriting is used to manipulate URL paths before the request is handled by the Web server. The URL rewriting module does not know which handler will eventually process the rewritten URL. In addition, the actual request handler might not know that the URL has been rewritten.
- ASP.NET routing is used to dispatch a request to a handler based on the requested URL path. As opposed to URL rewriting, the routing module knows about the handlers and selects the handler that should generate a response for the requested URL. You can think of ASP.NET routing as an advanced handler-mapping mechanism.
In addition to these conceptual differences, there are the following functional differences between IIS URL rewriting and ASP.NET routing:
- The IIS URL Rewrite module can be used with any type of Web application, which includes ASP.NET, PHP, ASP, and static files. ASP.NET routing can be used only with .NET Framework-based Web applications.
- The IIS URL Rewrite module works the same way regardless of whether integrated or classic IIS pipeline mode is used for the application pool. For ASP.NET routing, it is preferable to use integrated pipeline mode. ASP.NET routing can work in classic mode, but in that case the application URLs must include file name extensions or the application must be configured to use "*" handler mapping in IIS.
- The IIS URL Rewrite module can make rewriting decisions based on domain names, HTTP headers, and server variables. By default, ASP.NET routing works only with URL paths and with the HTTP-Method header.
- In addition to rewriting, the URL Rewrite module can perform HTTP redirection, issue custom status codes, and abort requests. ASP.NET routing does not perform these tasks.
- The URL Rewrite module is not extensible in its current version. ASP.NET routing is fully extensible and customizable.
Which Option Should You Use?
What does all this information mean if you need to choose a technology to enable clean URLs for your Web applications? In this section, we explain how to make this choice.
If your Web application is built by using anything except ASP.NET, use the IIS URL Rewrite module. Otherwise, the rules are:
- If you are developing a new ASP.NET Web application that uses either ASP.NET MVC or ASP.NET Dynamic Data technologies, use ASP.NET routing. Your application will benefit from native support for clean URLs, including generation of clean URLs for the links in your Web pages. Note that ASP.NET routing does not support standard Web Forms applications yet, although there are plans to support it in the future.
- If you already have a legacy ASP.NET Web application and do not want to change it, use the URL Rewrite module. The URL Rewrite module lets you translate search engine-friendly URLs into a format that your application currently uses. Also, it lets you create redirect rules that can be used to redirect search engine crawlers to clean URLs.
In practice, however, the choice does not have to be either/or. The technologies can be used together and can complement each other. In the following sections, we outline some scenarios where you can use ASP.NET routing and IIS URL rewriting together.
Enforcing canonical URLs for your application.
You should force the use of http://www.mysite.com/home/about instead of http://mysite.com/Home/About.
When a Web client requests a URL that does not conform to the format
that you want, the client is redirected to a canonical URL. In this
scenario, you can use the URL Rewrite module to enforce canonical URLs
and perform redirection, and use ASP.NET routing to select a handler
that would process the requested URL path.
Conclusion
Either IIS URL rewriting or ASP.NET routing can be used to implement URL manipulation scenarios for your Web application.
ASP.NET routing is a solution that is optimized for ASP.NET, thus it may be preferable for Web developers who design their ASP.NET applications from the ground up and want to have a clean URL structure.
IIS URL rewriting is a generic URL manipulation mechanism that addresses a multitude of scenarios.
In particular, it can be used by Web developers as well as Web server/site administrators to enable clean URLs for existing Web applications without modifying the application code.
IIS URL Rewriting and ASP.NET Routing的更多相关文章
- 001. Asp.Net Routing与MVC 之(基础知识):URL
URL(Uniform Resoure Locator:统一资源定位器)是WWW页的绝对地址.URL地址格式排列为:scheme://host:port/path. 例如 http://www.zn. ...
- IIS URL Rewrite – Installation and Use
IIS URL Rewrite – Installation and Use Posted by Nick LeFevre | Leave a reply IIS URL Rewrite Instal ...
- ASP.NET路由[ASP.NET Routing]
ASP.NET路由[ASP.NET Routing] ASP.NET路由允许你在使用URL时不必匹配到网站中具体的文件,因为这个URL不必匹配到一个文件,你使用了描述用户行为且更容易被用户理解的URL ...
- ASP.NET Routing
ASP.NET Routing Other Versions ASP.NET routing enables you to use URLs that do not have to map to ...
- 003. Asp.Net Routing与MVC 之一: 请求如何到达MVC
基础知识 本文用到的基础知识:URL.HttpModule 与 HttpHandler.IIS 的请求处理过程. URL HttpModule与HttpHandler IIS7.0的请求处理过程 OK ...
- .NET/ASP.NET Routing路由(深入解析路由系统架构原理)
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- .NET/ASP.NET Routing路由(深入解析路由系统架构原理)http://wangqingpei557.blog.51cto.com/1009349/1312422
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- NET/ASP.NET Routing路由(深入解析路由系统架构原理)(转载)
NET/ASP.NET Routing路由(深入解析路由系统架构原理) 阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模 ...
- IIS 7.0 的 ASP.NET 应用程序生命周期概述(转载)
IIS 7.0 的 ASP.NET 应用程序生命周期概述更新:2007 年 11 月本主题介绍在 IIS 7.0 集成模式下运行以及与 IIS 7.0 或更高版本一起运行的 ASP.NET 应用程序的 ...
随机推荐
- mysql limit和offset用法
limit和offset用法 mysql里分页一般用limit来实现 1. select* from article LIMIT 1,3 2.select * from article LIMIT 3 ...
- django_rest framework 接口开发(二)
1 a. 认证 - 仅使用: from django.views import View from rest_framework.views import APIView from rest_fram ...
- Python基础Day5
一.字典 ①字典是python的基础数据类型之一 ②字典可以存储大量的数据,关系型数据 ③字典也是python中唯一的映射类的数据类型 字典是以键值对的形式存在的,{键:值} 字典的键必须是不可变的数 ...
- kvm虚拟机在线调整硬件配置
#centos5.x版本不支持动态调整内存,CPU,以下是在centos6.x上测试 1.查看虚拟机信息 shell> virsh dumpxml cos_v1 | head -n 10 < ...
- Manjaro安装mysql-5.7折腾小记
安装前准备: 现在Arch官方源是MariaDB,所以得从mysql官网下载,地址:https://www.mysql.com/downloads/ 选择一个合适的版本下载: 下载下来先将压缩文件解压 ...
- 基于Java+Selenium的WebUI自动化测试框架(二)-----页面操作接口
在有了基础的Position类之后,我们需要考虑我们在寻找完页面元素之后,需要做什么.这个“做”什么,可以理解为我们在页面上需要对应的一系列动作.比如:点击,输入,切换窗口,寻找元素,判断元素是否存在 ...
- Factorization Machines
- python练习题(三)
题目: 一.二选一 1.每个区生成1个符合身份证规则的身份证号码 2.随机生成10个符合身份证规则的身份证号码 二.要求: 1.身份证属于南京市 2.出生日期为1980-1-1 至 2019-8-1的 ...
- re模块与正则
一.正则 正则就是用来筛选字符串中的特定的内容 正则表达式与re模块的关系: 1.正则表达式是一门独立的技术,任何语言都可以使用 2.python中药想使用正则表达式需要通过调用re模块 正则应用场景 ...
- 如何学好java?
忻州seo:如何学好java?想必对于任何一个在学习java的朋友们,都会在学习过程中遇到一些问题.例如:Java反射机制是什么?小编也是学习java编程的,现在给大家简单介绍一下:Java反射机制就 ...