Click here to Skip to main content
Email Password   helpLost your password?


Introduction

I have always had problems finding a suitable ASP.NET URL Rewriter that fully meets my needs, so about one year ago, after much frustration with attempting to follow third party open-source code and related poor documentation, I decided to write my own. I have since repackaged this URL Rewriter/ Redirector into the name of nUrlRewriter Version 2. nUrlRewriter has been posted on popular download sites, such as codeplex.com and code.msdn.microsoft.com

nUrlRewriter is a ASP.NET Http Module written in managed C# code. nUrlRewriter examines incoming Http requests and applies user defined criteria which may result in a Http request being redirected or rewritten. Web pages within existing web sites are often archived or retired, however many Internet based hyperlinks may exist for such web pages. nUrlRewriter solves this problem by providing a facility which can easily redirect or rewrite such Http requests to other web site web pages or web applications. For example, a discontinued product web page may be redirected to a general product category web page. nUrlRewriter differentiates itself from other redirectors/rewriters in that nUrlRewriter also supports the IIS7 Integrated Pipeline, enabling nUrlRewriter to redirect/rewrite any incoming web application URL supported by the IIS7 web server, such as but not limited to native HTML applications (htm, html), classic ASP applications (asp), PHP applications (php) as well as ASP.NET (aspx) applications.

Incoming Http requests which are redirected are returned to the originating browser with a status code of either 301 (permanent) or 302 (temporary) to indicate that the requested web page has been moved to a new target URL provided to the browser. the browser will then issue a new Http request for the new URL. Http status code 301 indicates that the URL has been permanently moved and the browser should use the new URL in any new Http requests. Http status code 302 indicates that the URL has been temporarily moved and the browser should use the new URL only for the outstanding Http request.

Incoming Http requests which are rewritten are rewritten to a different URL location within IIS. Since the originating browser is not informed of the URL rewrite, the browser URL address bar will continue to display the originating URL before the URL rewrite.

nUrlRewriter works equally as well with IIS5 and IIS6.

Background

Clearly, with an all new internal architecture and with new enriched Remote Administration and Feature Delegation enhancements, IIS7 opens up a new generation of web hosting and demands a new generation of support infrastructure tools as well; such as Url Rewriters/ Redirectors.

nUrlRewriter not only works well in an IIS5 or IIS6 environment, but nUrlRewriter takes advantage of the new IIS7 Integrated ASP.NET Pipeline to simplify communications between native HTML applications (.htm, .html), classic ASP (.asp), PHP applications (.php) and ASP.NET (.aspx).

nUrlRewriter can be used for the following:

  1. To redirect/rewrite in case of retired or archived web pages.
  2. To rewrite from a friendly URL format to an internal URL format.
  3. To redirect to secondary folder locations; for example language specific web site content may reside in separate folders, or a single IP address may be hosting multiple web sites, with the domain specific content residing in sub-folders.
  4. To provide for URL specific robots.txt files. For example if a single IP address is supporting multiple web sites, then web site specific robots.txt files can be returned when requested.

Redirecting Incoming Http Requests

Redirecting Incoming Http Requests

Rewriting Incoming Http Requests

Rewriting Incoming Http Requests

Using with IIS Version 5 or 6

nUrlRewriter executes in the form of a Http Module, so nUrlRewriter must be defined in the web.config <system.web> <httpModules> configuration section, as illustrated below:

   1:    <system.web>
   2:      <httpModules>
   3:        <add name="nUrlRewriter"
   4:             type="nUrlRewriter.HttpModule, 
   5:                    nUrlRewriter,
   6:                    Version=2.0.0.0,
   7:                    Culture=neutral,
   8:                    PublicKeyToken=741b921e11e02781"/>      
   9:      </httpModules>
  10:    </system.web>

To configure specific nUrlRewriter options, the nUrlRewriter web.config configuration section must now be declared, as illustrated below:

   1:    <configSections>
   2:      <section name="nUrlRewriter" 
   3:               type="nUrlRewriter.Configuration2.Configuration, 
   4:                      nUrlRewriter,
   5:                      Version=2.0.0.0,
   6:                      Culture=neutral,
   7:                      PublicKeyToken=741b921e11e02781"/>
   8:    </configSections>

Once the nUrlRewriter Http Module is defined and the nUrlRewriter configuration section is declared, the nUrlRewriter specific configuration section must be defined within the web.config.

I am currently supporting two web sites; my corporate web site - www.sanibellogic.com and my personal web site - www.plippard.com. The entry point for both sites is at the root level (wwwRoot), with a common IP address. Any future additional web sites being hosted will also share the same IP address. The root level of my web site redirects based on domain name, and then more specific redirect/ rewrite logic is applied at the sub-folder (or actual web site sub-folder) level. Essentially, at the wwwRoot level, sanibellogic.com domains are redirected to the “/SL” sub-folder, and plippard.com domains are redirected to the “/PGL” sub-folder. Because these sites are currently being hosted on IIS6, IIS7 specific features are not currently used. IIS7 specific features will be discussed later in this article.

The following exhibit shows the root level nUrlRewriter configuration section for achieving the above discussed domain redirection:

   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <nUrlRewriter xmlns="http://schemas.sanibellogic.com/nUrlRewriter/config/2/0/0/0"
   3:                enabled="true"
   4:                trace="false">
   5:    <urls>
   6:      <clear/>
   7:   
   8:      <add name="RuleSanibelLogic"
   9:           action="redirect"
  10:           ignoreCase="true" 
  11:           redirectType="temporary"
  12:           transformType="RegExReplace"
  13:           fromScope="absolute"
  14:           from="^http(?&lt;SSL&gt;[s]?)://(www.)?sanibellogic.com/(?&lt;WebPage&gt;(.*))$"
  15:           to="http${SSL}://www.sanibellogic.com/sl/${WebPage}" />
  16:   
  17:      <add name="RulePLippard"
  18:           action="redirect"
  19:           ignoreCase="true"
  20:           redirectType="temporary"
  21:           transformType="RegExReplace"
  22:           fromScope="absolute"
  23:           from="^http(?&lt;SSL&gt;[s]?)://(www.)?plippard.com/(?&lt;WebPage&gt;(.*))$"
  24:           to="http${SSL}://www.plippard.com/pgl/${WebPage}" />
  25:   
  26:    </urls>
  27:  </nUrlRewriter>

The above configuration section exhibit primarily examines the incoming domain name, transforms the absence of a sub-domain to "www." and then redirects the incoming request to a defined ASP.NET application sub-folder (either /SL or /PGL) based on whether the domain is "sanibellogic.com" or "plippard.com". All sub-folder or query string content following the domain name is also appended to the redirected request.

Once the incoming request is intercepted and redirected to the proper ASP.NET application sub-folder, nUrlRewriter (operating in the context of the /SL or /PGL sub-folder) will again have an opportunity to intercept and redirect or rewrite the new incoming request, . The exhibit below shows the ASP.NET application folder level configuration section used by nUrlRewriter when operating in the context of the /SL sub-folder:

   1:  <nUrlRewriter xmlns="http://schemas.sanibellogic.com/nUrlRewriter/config/2/0/0/0"
   2:                enabled="true"
   3:                trace="false">
   4:    
   5:    <urls>
   6:      <clear/>
   7:   
   8:      <!-- Rewrite one time DownloadMe.aspx root level DownloadMe page to new location,
   9:            Note: rewriteType="transferrequest" requires IIS7 Integrated Pipeline mode -->
  10:      <add name="RuleDownloadMe"
  11:           action="rewrite"
  12:           rewriteType="rewritePath"
  13:           ignoreCase="true"
  14:           transformType="RegExReplace"
  15:           from="~/DownloadMe.aspx(?&lt;QStrings&gt;(.*))$"
  16:           to="~/Common/S/DownloadMe.aspx${QStrings}" />
  17:   
  18:      <!-- Rewrite ECartDownload.aspx web page to new location,
  19:            Note: rewriteType="transferrequest" requires IIS7 Integrated Pipeline mode -->
  20:      <add name="RuleECartDownload"
  21:           action="rewrite"
  22:           rewriteType="rewritePath"
  23:           ignoreCase="true"
  24:           transformType="RegExReplace"
  25:           from="~/Common/ECartDownload.aspx(?&lt;QStrings&gt;(.*))$"
  26:           to="~/Common/S/ECartDownload.aspx${QStrings}" />
  27:   
  28:      <!-- Rewrite PaypalIPN web page to new location,
  29:            Note: rewriteType="transferrequest" requires IIS7 Integrated Pipeline mode -->
  30:      <add name="RulePaypalIPN"
  31:           action="rewrite"
  32:           rewriteType="rewritePath"
  33:           ignoreCase="true"
  34:           transformType="RegExReplace"
  35:           from="~/Common/PaypalIPN.aspx(?&lt;QStrings&gt;(.*))$"
  36:           to="~/Common/S/PaypalIPN.aspx${QStrings}" />
  37:   
  38:      <!-- Redirect one time Products.aspx root level Products page to new location -->
  39:      <add name="RuleProducts"
  40:           action="redirect"
  41:           ignoreCase="true"
  42:           redirectType="permanent"
  43:           transformType="RegExReplace"
  44:           from="~/Products.aspx(?&lt;QStrings&gt;(.*))$"
  45:           to="~/Common/Products.aspx${QStrings}" />
  46:   
  47:      <!-- Redirect discontinued Products.aspx DotNetNuke SSLRedirect queries -->
  48:      <add name="RuleDotNetNuke00200"
  49:           action="redirect"
  50:           ignoreCase="true"
  51:           redirectType="permanent"
  52:           transformType="RegExReplace"
  53:           from="~/Common/Products.aspx\?Cat=DotNetNuke&amp;PLong=00200$"
  54:           to="~/Common/Products.aspx?Cat=ASP.NET&amp;PLong=00401" />
  55:   
  56:      <!-- Redirect discontinued Products.aspx DotNetNuke SSLRedirect SDK queries -->
  57:      <add name="RuleDotNetNuke00201"
  58:           action="redirect"
  59:           ignoreCase="true"
  60:           redirectType="permanent"
  61:           transformType="RegExReplace"
  62:           from="~/Common/Products.aspx\?Cat=DotNetNuke&amp;PLong=00201$"
  63:           to="~/Common/Products.aspx?Cat=ASP.NET&amp;PLong=00402" />
  64:   
  65:      <!-- Redirect discontinued Products.aspx DotNetNuke SmartNews queries -->
  66:      <add name="RuleDotNetNuke00202"
  67:           action="redirect"
  68:           ignoreCase="true"
  69:           redirectType="permanent"
  70:           transformType="RegExReplace"
  71:           from="~/Common/Products.aspx\?Cat=DotNetNuke&amp;PLong=00202$"
  72:           to="~/Common/Products.aspx?Cat=ASP.NET" />
  73:   
  74:      <!-- Redirect discontinued Products.aspx DotNetNuke SmartNews SDK queries -->
  75:      <add name="RuleDotNetNuke00203"
  76:           action="redirect"
  77:           ignoreCase="true"
  78:           redirectType="permanent"
  79:           transformType="RegExReplace"
  80:           from="~/Common/Products.aspx\?Cat=DotNetNuke&amp;PLong=00203$"
  81:           to="~/Common/Products.aspx?Cat=ASP.NET" />
  82:   
  83:      <!-- Redirect discontinued Products.aspx DotNetNuke HttpCompressionAgent queries -->
  84:      <add name="RuleDotNetNuke00204"
  85:           action="redirect"
  86:           ignoreCase="true"
  87:           redirectType="permanent"
  88:           transformType="RegExReplace"
  89:           from="~/Common/Products.aspx\?Cat=DotNetNuke&amp;PLong=00204$"
  90:           to="~/Common/Products.aspx?Cat=ASP.NET&amp;PLong=00400" />
  91:   
  92:      <!-- Redirect discontinued Products.aspx DotNetNuke product category -->
  93:      <add name="RuleDotNetNuke"
  94:           action="redirect"
  95:           ignoreCase="true"
  96:           redirectType="permanent"
  97:           transformType="RegExReplace"
  98:           from="~/Common/Products.aspx\?Cat=DotNetNuke$"
  99:           to="~/Common/Products.aspx?Cat=ASP.NET" />
 100:      
 101:    </urls> 
 102:   
 103:  </nUrlRewriter>

As can be seen from the above nUrlRewriter configuration sections, nUrlRewriter can be easily extended without code source changes, simply by defining the actions required in the configuration section.

Using with IIS Version 7 (Windows Server 2008 and Vista)

Once released, I fully expect to take advantage of the much publicized and anticipated Windows Server 2008 IIS7 features. When one plans on utilizing the more advanced IIS7 features, and one’s web application is defined to IIS7 as executing in “Integrated ASP.NET Pipeline” mode then nUrlRewriter is defined in a slightly different manner within the web.config. The nUrlRewriter Http Module is now defined within the new <system.webserver> configuration section, illustrated below:

   1:    <system.webServer>
   2:      <modules>
   3:        <add name="nUrlRewriter"
   4:             type="nUrlRewriter.HttpModule, 
   5:                    nUrlRewriter,
   6:                    Version=2.0.0.0,
   7:                    Culture=neutral,
   8:                    PublicKeyToken=741b921e11e02781"/>
   9:      </modules>    
  10:    </system.webServer>

The nUrlRewriter configuration section continues to be declared and defined as with IIS5/6, illustrated as follows:

   1:    <configSections>
   2:      <section name="nUrlRewriter"
   3:               type="nUrlRewriter.Configuration2.Configuration, 
   4:                      nUrlRewriter,
   5:                      Version=2.0.0.0,
   6:                      Culture=neutral,
   7:                      PublicKeyToken=741b921e11e02781"/>
   8:    </configSections>

One of the nUrlRewriter configuration options available with IIS7 is the ability to rewrite/ redirect between any web application supported by the IIS7 web server, such as but not limited to native HTML applications (htm, html), classic ASP applications (asp), PHP applications (php) as well as ASP.NET (aspx) applications. To achieve this objection (for example), one would configure the nUrlRewriter configuration section as follows:

   1:  <nUrlRewriter xmlns="http://schemas.sanibellogic.com/nUrlRewriter/config/2/0/0/0"
   2:                              enabled="true"
   3:                              trace="false">
   4:   
   5:      <topLevelExtensions>
   6:          <clear/>
   7:          <add extension="asp" />
   8:          <add extension="aspx" />
   9:          <add extension="htm" />
  10:          <add extension="html" />
  11:          <add extension="php" />
  12:      </topLevelExtensions>
  13:   
  14:      <urls>
  15:          <clear/>
  16:   
  17:          <!-- Redirect WordPress blog URL, which was a sub-folder within an ASP.NET App
  18:                      to new ASP.NET BlogEngine.Net sub-folder -->
  19:          <add name="RuleBlog"
  20:                   action="redirect"
  21:                   from="~/support/wpblog/(.+)"
  22:                   to="~/support/beblog/" />
  23:      </urls>
  24:   
  25:  </nUrlRewriter>

Please note that the topLevelExtensions tag defines the candidate web page extensions, required for PHP application visibility in this example.

With IIS7, another common use of nUrlRewriter will be support for multiple robots.txt files. The robots.txt file is ordinarily required to be at the root level of a web site. The following nUrlRewriter configuration section illustrates rewriting a web request for a root level robots.txt file to a sub-folder resident robots.txt, making its sub-folder location transparent to the invoking search engine. The to attribute MUST be transformed into a relative URL location, which starts with "~/", because both the System.Web.HttpServerUtility.TransferRequest and System.Web.HttpContext.RewritePath methods require a relative URL path. Please note that the "txt" extension must also be included within the topLevelExtensions collection.

   1:    <nUrlRewriter xmlns="http://schemas.sanibellogic.com/nUrlRewriter/config/2/0/0/0"
   2:                  enabled="true"
   3:                  trace="false">
   4:   
   5:          <topLevelExtensions>
   6:              <clear/>
   7:                  <add extension="asp" />
   8:                  <add extension="aspx" />
   9:                  <add extension="htm" />
  10:                  <add extension="html" />
  11:                  <add extension="php" />
  12:                  <add extension="txt" />
  13:   
  14:          </topLevelExtensions>
  15:          
  16:          <urls>
  17:              <clear/>
  18:   
  19:              <!-- Based on incoming domain of SanibelLogic.com, rewrite to a -->
  20:              <!-- sub-folder location for the robots.txt file -->
  21:              <add name="RuleSanibelLogicRobots"
  22:                      action="rewrite"
  23:                      rewriteType="transferRequest"
  24:                      fromScope="absolute"
  25:                      from="^http(?&lt;SSL&gt;[s]?)://(www.)?sanibellogic.com/(?&lt;robotsFile&gt;(robots.txt))$"
  26:                      to="~/SL/$(robotsFile)" />
  27:   
  28:              <!-- Based on incoming domain of PLippard.com, rewrite to a -->
  29:              <!-- sub-folder location for the robots.txt file -->
  30:              <add name="RulePLippardRobots"
  31:                      action="rewrite"
  32:                      rewriteType="transferRequest"
  33:                      fromScope="absolute"
  34:                      from="^http(?&lt;SSL&gt;[s]?)://(www.)?plippard.com/(?&lt;robotsFile&gt;(robots.txt))$"
  35:                      to="~/PGL/$(robotsFile)" />
  36:   
  37:          </urls>
  38:    </nUrlRewriter>

A URL rewriting/ redirecting web component is essential for effective management of multiple as well as single web sites. nUrlRewriter utilizes new and advanced IIS7 Integrated ASP.NET Pipeline features to ensure that all web applications, such as but not limited to native HTML applications (htm, html), classic ASP applications (asp), PHP applications (php), and ASP.NET applications (aspx) are integrated in an effective manner. nUrlRewriter also utilizes regular expressions and a flexible configuration design to ensure ease of expansion without source code changes. nUrlRewriter documentation in .chm help file form is available with the VS.NET 2008 source code project download.

History

18-Apr-2008 - Initial Release (although I have been executing in production under a different name for one year)

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
QuestionProblem with folder level rewriting
GrantSt
7:40 21 Aug '08  
I'm trying to rewrite urls like ~/Article/67 to ~/Article.aspx?Article=67 but I can't get it working.

I've used the following:

<add name="Articles"
action="rewrite"
from="~/Article/(\d+)"
to="~/Article.aspx?Article=$1" />


However if I change the from expression to "~/Article/(\d+).htm" and then type the address in the browser as http://localhost/Article/76.htm then it works fine. It seams that if I don't have a file extension then the rewriter doesn't process the request.

I'm using IIS 7 on Vista.

How can I get this to work?

Thanks for any help,
Grant
AnswerRe: Problem with folder level rewriting
Philip Lippard
13:40 27 Aug '08  
Probably would be best if I could get you to run a nUrlRewriter trace so I see exactly what is coming in.....and I can then implement a fix for you. Send the trace to support@sanibellogic.com and be sure to reference nUrlRewriter and Code Project in the subject line.

Thanks
GeneralFor Simplest Way of writing URL Rewriting
DotNetGuts
11:41 24 Jul '08  
I have wrote a article which explains how to write URL Rewriting with simplest example, step-by-step.

http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html[^]

DotNetGuts
"Lets Make Programming Easy"

Logon to www.DotNetGuts.2ya.com
Join Us @ DotNetGuts@YahooGroups.com

QuestionRewriting a URL [modified]
jcsernik
12:36 30 May '08  
I am trying to set this up so that when a non-ssl SharePoint site is accessed from an SSL IIS virtual, the url for WSS's search string can be modified by checking to see if u=https is in the urls, and if so , delete the s. This has to be done before the url or query string is sent to the aspx page for processing.

An example is:
https://test.wss.local/_layouts/searchresults.aspx?k=usersearchitem&u=https%3A%2F%2Ftest%2Ewss%2Elocal


Needs to be rewritten to:
https://test.wss.local/_layouts/searchresults.aspx?k=usersearchitem&u=http%3A%2F%2Ftest%2Ewss%2Elocal


I believe the regex ^((.*&)?u=http)s(.+)$ sets it up properly to locate the string, and should allow the string to be rebuilt w/o the s, but I am not familiar with how to set up the web.config to perform this action. Is it possible for me to get a sample to try out and see if I can get it working? I am pretty new to this in general.

Thanks!

modified on Monday, June 9, 2008 2:06 PM

GeneralRe: Rewriting a URL
Philip Lippard
3:30 31 May '08  
In the Appendix of the nUrlRewriter documentation are some reference sites for understanding of regular expressions. These sites should help.
GeneralRe: Rewriting a URL
jcsernik
9:06 9 Jun '08  
I have read the documentation, but cannot find anything that matches what I am trying to do, or anything that seems to point me in the right direction.

Using the regex I posted earlier should find in the given URL 3 things, the url up through the u=http, the url up through the u=https, and the url of everything after the u=https, then I should be able to set the to= parameter to output the first and third matches as a rewrite, and thus eliminate the s.

the problem I am having is I do not seem to understand how to syntax that into the XML format used here. I understand how to incorporate this into something like mod_rewrite for Apache, but the syntax used here escapes me.
GeneralRe: Rewriting a URL
Philip Lippard
9:17 9 Jun '08  
Read the samples I replied to on CodePlex at...

http://www.codeplex.com/nUrlRewriter/Thread/View.aspx?ThreadId=29226

See if these samples help....if not....then post back what you have configured so far. Keep in mind....you do not necessarily need to check for each and every character in the URL.....and you have to use escape characters where apopropriate. You can find the escape characters on the Internet.
GeneralRe: Rewriting a URL
Philip Lippard
9:39 9 Jun '08  
The nUrlRewriter trace facility also helps you see how regular expressions are behaving to relation to specific URLs.
GeneralQuestion
Member 3808614
2:18 27 May '08  
Hi,
I have a website using SSL and hardware load balancing(Portbinding).   We are getting problems when our application generates 302 redirect, which is generating a bad URL, which is removing HTTPS and appending port information.   Is it possible to change the example ERRORURL to CORRECTURL for ALL requests/redirects with UrlRewriting.NET???

REQUEST PROCESS
===============
HTTPS URL POST --> SSL offloaded --> HTTP(80) request sent to binding of real server ip + port 8240 -->   302 sent to client with appended port information and HTTP.   This fails as no HTTP traffic allowed inbound.

ERRORURL
=======
Location: http://uat71.hostnameremoved.com:8240/Default.aspx?tabid=91

CORRECTURL
==========
Location: https://uat71.hostnameremoved.com/Default.aspx?tabid=91



HTTP HEADER example:
===================

POST /Particulier/Accueil/tabid/74/Default.aspx HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, application/x-silverlight, */*
Referer: https://uat71.hostnameremoved.com/Particulier/Accueil/tabid/74/Default.aspx
Accept-Language: en-gb
Content-Type: multipart/form-data; boundary=---------------------------7d815aac177e
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.2; .NET CLR 3.5.21022)
Host: uat71.hostnameremoved.com
Content-Length: 1667
Connection: Keep-Alive
Cache-Control: no-cache


HTTP/1.1 302 Found
Date: Fri, 23 May 2008 12:35:16 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: http://uat71.hostnameremoved.com:8240/Default.aspx?tabid=91
Set-Cookie: language=fr-FR; path=/; HttpOnly
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 167


=============================

Many thanks

Jason
GeneralRe: Question
Philip Lippard
2:46 27 May '08  
Should probably work.
GeneralRewriting asp and asp.net URLs
buosc
8:19 6 May '08  
Hi, I'm not exactly clear if I can do what I'd like using this. Can you point tell me if this would work (and whether I'd need IIS7 too)?

We are in the process of converting a very high use set of asp pages to asp.net. While we are in the process of doing the conversion (which we envision taking quite a long time) we'd like to roll out the asp.net pages as we go but not require users to use the new url. So, we'd like to intercept the request and if the requested asp page has been converted then rewrite the url to the corresponding new asp.net page and if it hasn't yet been converted then go ahead with the classic asp page as initially requested.

Since all requests will come in as asp pages I assume we'd need to configure a wildcard extension to aspnet_isapi.dll so the httpmodule can be run. Then perform the rewrite (when applicable) and have the request processed.

Questions:
- given that this is a high volume site, is the execution of the httpmodule for every request going to adversely impact performance?
- will we need IIS7 to handle the classic asp pages (ie those where no rewrite occurs)?
- does what I am saying even make sense?

Any help appreciated,
Jon
GeneralRe: Rewriting asp and asp.net URLs
Philip Lippard
14:58 9 May '08  
You can do what you are thinking of doing....rewriting between classic ASP and ASP.NET.

Best thing to do is to use IIS7 and not reconfigure classic ASP to aspnet_isapi.dll as you were thinking. Simply use IIS7 and include the appropriate topLevelExrtensions in the nUrlRewriter configuration.

Philip
GeneralRe: Rewriting asp and asp.net URLs
buosc
9:34 12 May '08  
Thanks for the response. It turns out I will not be allowed to use IIS7. What are my options to rewrite to a classic asp page from an asp.net page under IIS6?
GeneralRe: Rewriting asp and asp.net URLs
Philip Lippard
15:36 12 May '08  
You could try defining .ASP web page extensions to come into ASP.NET and redirect them all....but it would have to be "redirect all or nothing"....you would have to test this and yes if it would work.
QuestionRewriting folders
Jenya Y.
12:14 22 Apr '08  
Philip, thanks for sharing this.

Can it rewrite folders and not just files in IIS7? For example, http://domain.com/books to http://domain.com/default.aspx?section=books
GeneralRe: Rewriting folders
Philip Lippard
20:01 22 Apr '08  
Yes...not a problem.
QuestionRe: Rewriting folders
Jenya Y.
21:40 22 Apr '08  
I assume that in IIS lower than 7 it won't work, correct?
AnswerRe: Rewriting folders
Philip Lippard
9:25 30 Apr '08  
No....incorrect assumption. It will work fine with IIS v5 or v6.
QuestionLooks good
stixoffire
21:47 18 Apr '08  
I have a huge number of links - and going to the config file is slow - in comparison I cna retunr a DB instance of the page much faster - now how to do that with your code or rewriter.net is a mystery to me.

One other question how does this work with postbacks ?
GeneralRe: Looks good
mischa_k
6:12 22 Apr '08  
All data is as fast as the cache used to store it.
GeneralRe: Looks good
Philip Lippard
20:03 22 Apr '08  
Postbacks are not usually a problem....one just needs to consider what the GET and POST URLs will look like....and plan accordingly with the nUrlRewriter definitions....
GeneralNice work
Viral Upadhyay
21:45 18 Apr '08  
I didnt test it but its new feature and i must say will be very useful to developer like me.
Very Good work Rose

Viral
YahooID : just_viral

GeneralGood! question
zhaojicheng
19:56 18 Apr '08  
I donnt know.
how can i to do that ..
eg:
a.codeproject.com =www.codeproject.com/default.aspx?username=a
b.codeprojectc.com =www.codeproject.com/default.aspx?username=b
thanks
GeneralRe: Good! question
leppie
23:21 18 Apr '08  
Unfortunately not Smile

You will need DNS entries for that Smile

xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 3 out now

GeneralRe: Good! question
pulsar
2:11 19 Apr '08  
from what I understand it might be possible if you enable "catch-all" for *.codeproject.com and use a rewriting rule like:

From:
(?<userName>([^.]+))\.codeproject\.com

To:
http://www.codeproject.com?username=${userName}

The rule does not respect url parameters, grab a copy of Mastering Regular Expressions and figure it out Smile Not that difficult.

By the way, I find the named replacement "groups" kinda funny, can the engine also deal with $1-$n instead of the named placeholders?


http://codewut.de


Last Updated 18 Apr 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010