views:

382

answers:

3

In asp.net 3.5, I'm rewriting the url

http://www.abc.com/archive/1108/harpersdecember

to the following

http://www.abc.com/article.aspx?docId=78

I'm using this code to do it:

                Context.RewritePath("/article.aspx?docId=78");

It works fine locally but when I upload to the remote web server, I get a 404 when trying to reference the above page. Any suggestions why it works locally but not remotely?

+2  A: 

You may need to create a wildcard mapping in IIS on the remote server so that all requests are processed by ASP.Net. If you do not do this any URLs without .ASPX on the end will not run through your URL rewriting code.

There is a good explanation of this (and other reasons you might use it) on Scott Guthrie's blog.

Generic Error
+1  A: 

Not "may" - you definitely need to create a wildcard mapping. Visual Studio uses the cassini web server which essentially passes all requests through .net. IIS only forwards specific mapped requests (by default .aspx, .asmx, etc..) to .net - rewriting a URL in asp.net requires adding a new mapping to get the request to asp.net in the first place

annakata
A: 

Sounds to me like the production server does not have a default aspx page, ie: default.aspx. If it did, it would reroute the request to your handler.

Easy way to verify this, would be to create a directory and place a default.aspx file in it and try to request it using only the dir name, ie: server.com/newdir/ If that gives you a 404, then you know it for sure.

Ruvan Fernando