I need to redirect a user to a different page if they visit a certain set of pages in a web. There is one condition: I’m not allowed to touch the IIS. I have googled around and found a thing called the custom HttpHandler for WSS 3.0. It sounded like something that I can use to capture the URL the user enters (the most malicious way to get to a page that should really be redirected) and redirect them to another page/web. But having not have the chance to use it yet, I was wondering am I on the right track by using a Custom HttpHandler to redirect a user to a different page in Sharepoint using C#?
Many thanks.
HttpHandlers are used by IIS to “handle” different document types, for instance you have separate.asmxhandle,.aspxhandler,.ascxhandler, etc.Look into
SPUtility.RedirectAlternatively, you can look into Using Disposable Windows SharePoint Services Objects.
–EDIT–
This is in response to your comment; you are thinking in the right direction
Redirect()if you like the url, else otherwise.But for your Custom HttpHandler to work, it should be called first – so in your config file you will have to provide the value in
path. Usually an extension is added here. But you can replace that with a*to work for all request. I believe that would work.–EDIT–
This is in response to your comment. Assuming that you have “access” to pages so that you can write javascript in it, you can use the javascript in following way.
You may call the above javascript in the page’s
OnLoadevent.