I’m working on a website in aspx where a user can go to a url similar to “www.website.com/referralname” or “www.website.com/otherreferralname” and will be redirected to http://www.website.com/genericform.aspx?referral=referralname
I’m not the original designer of the site, and I’d like to add as little as possible, so I’m hoping there’s a way to do this through the webconfig, rather than having to add a redirect page and switch case every possible referralname.
I’ve explored the possibility of using
<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="~/404.aspx"/>
</customErrors>
But there is already code in the AppCode that somehow is overriding or supplanting mine, and anyhow it only shows the default 404 page. Any advice is greatly appreciated.
Edit: I’ve been informed that a .aspx won’t work with the customErrors tag there, so that might be part of the problem. I’d also appreciate clarification on that issue as well. I will be learning a lot today!
Edit 2: So after doing a little more research, I think the search term that would have benefitted me is “Routing”. I’ve found this MSDN page which I think will lead me to my solution. If this works out for me, I’ll post a comment with the “answer” later.
You can lookup IHttpHandler and IHttpHandlerFactory. I use them on my wiki. I have pages that end in .wiki and do not exist, but get redirected to generic pages that load them from a database. You have to have access to the IIS server (or call your ISP) to get non-existent files by the extension you choose to still pass through to the Asp.Net software to get handled by it.
There are other ways of doing the same kinds of things.
PS To use my method, I had to have Full Trust on my server to get it to work. I’m convinced that it isn’t necessary, but I couldn’t figure it out.
Edit:
These are the bookmarks I have saved:
Serving Dynamic Content with HTTP Handlers
How To Create an ASP.NET HTTP Handler