3

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 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.

2
  • did you try to set them mode to "on" Commented May 24, 2011 at 18:43
  • Yes, it still goes to the default server 404 error page. Thank you though. Commented May 24, 2011 at 18:47

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

I've been going over this article about IHttpHandler and IHttpHandlerFactory: link But it's a little fast and loose, so if you know of any more detailed information sources, that would also be helpful. (Sorry that I had to edit this comment 3 times, I'm still kind of new!)
@Christine I added some links to my post you can review.
1

Okay, so the thing that eventually ended up working was the following code added to the system.web area of the web.config folder

<urlMappings enabled ="true">
    <add url="~/referralname" mappedUrl="~/custom/sign-up.aspx?ref=referralname"/>
</urlMappings>

So simple, yet so elusive! I hope this helps others!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.