Rich
Rich

Reputation: 2174

How to write a global redirect in C#?

A client has sent out an email with a link containging a typo for a website we run [E.g. http://example.com/?id=123.]. What is the best way to re-direct anyone who visits the bad URL?

If someone clicks on the link, can we catch it in the Global.asax, checking if the path ends with "." then removing it and re-directing? If so, where in Global should it be?

If another method is better I'm happy to hear it; the most important thing is speed as this is needs to be nipped in the bud ASAP!

Upvotes: 0

Views: 345

Answers (3)

ALOToverflow
ALOToverflow

Reputation: 2699

If you happen to not have IIS 7.0 you can always use ISAPI_Rewrite (the free edition). Working mainly on regex you can redirect or rewrite any url.

http://www.helicontech.com/isapi_rewrite/

Upvotes: 0

FallenAvatar
FallenAvatar

Reputation: 4079

Its not the best solution, but you could use Application_BeginRequest in the global.asax file.

And better way if you are using IIS 7.0 is URL Rewriting

Upvotes: 2

Nick Allen
Nick Allen

Reputation: 12230

You need to use something like ISAPI_REWRITE for url re-writing in IIS (If IIS 6) because I'm not sure that that request would even be handled by .NET with that extension

Upvotes: 0

Related Questions