Redirecting nonexistent pages with query strings using web.config

I am working on an aspx website where the user can go to a URL like "www.website.com/referralname" or "www.website.com/otherreferralname" and will be redirected to www.website. com / genericform.aspx? referral = referralname

I am not the original website designer, and I would like to add as little as possible, so I hope that you have a way to do this through webconfig, instead of adding a redirect page and switch the case to all kinds of link names.

I have studied the possibility of using

<customErrors mode="RemoteOnly">
    <error statusCode="404" redirect="~/404.aspx"/>
</customErrors>

But AppCode already has code that somehow overrides or supplants mine, and in any case, it only shows the 404 page by default. Any advice is appreciated.

Edit: I was informed that .aspx would not work with the customErrors tag, so this could be part of the problem. I would also like clarification on this. I will learn a lot today!

Edit 2: So, after a little research, I think the search query that would benefit me is “Routing”. I found this MSDN page , which I think will lead me to my solution. If this works for me, I will post a comment with a “response” later.

+3
source share
2 answers

IHttpHandler IHttpHandlerFactory. . , .wiki , , . IIS ( -), , , Asp.Net, .

.

PS , , . , , .

Edit:

, :

HTTP

HTTP ASP.NET

+2

, , , , system.web web.config

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

, ! , !

+1

All Articles