tags:

views:

1197

answers:

4

Hello,

I wonder what the best approach is for a situation where I want to have the user type in

http://myserver/something/20

and get redirected (301 or 302) to

http://someotherserver/applications/something/modules/default.aspx?id=20

For .net 3.5 and IIS 7 I found some solutions, but unfortunately I am stuck with .net 3.0 and IIS 6.0 on Windows 2003, and I do not want to install anything on the server if possible. I can change the settings for the Virtual Directory though, and if I have to for the entire site.

HTTPModules and web.config are ASP.net only If I am not completely mistaken, hence that will not help as /20 is not sent to ASP.net per Default?

Can anyone give me some tips where I can set up something like that?

+2  A: 

The only way I have seen to do it without putting the 301 redirects directly into IIS Manager is to use Wildcard mapping

Link

Paul
+1  A: 

You might enlist the assistance of ASP.

Create a 404.asp file in your something folder with the content:-

<%

Dim id : id = CLng(Mid(Request.QueryString, InStrRev(Request.QueryString, "/")+1))
Response.Redirect "http://someotherserver/applications/something/modules/default.aspx?   id=" & id

%>

In Custom errors of the something folder in IIS manager tweak to URL and /something/404.asp

Note the querystring value passed to the 404 customer error page looks like:-

404;http://myserver:80/something/20

Edit: D'oh or you could use a 404.ashx custom error page and then use more familiar .NET code.

AnthonyWJones
+1  A: 

Map the .* extension to the same DLL as .aspx in the virtual directory's file mappings in Application Configuration. Then in the web.config's httpHandlers section, map the URL to the type.

Mark Cidade
+1  A: 
  1. In IIS, right click on the Virtual Directory, select Properties.
  2. Under the Directory tab, click the Configuration... button.
  3. Under the Mappings tab, under the Wildcard application maps (order of implementation): click the Insert... button.
  4. Browse and select C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll, leave Verify that the file exists unchecked.
  5. Move Up aspnet_isapi.dll to the top of the list.
  6. Click Ok, Ok, and try it. Try recycling the application pool if you don't see it work.

We had a situation where the .Net Routing was working on our development PCs but not on the test and production server with IIS 6 and Windows 2003. This fixed our problem.

James Lawruk