Click here to Skip to main content
15,924,317 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there! Trust your day went well! I am having a challenge that I have been battling to settle for a long time but could. Why? Maybe because I don't know the right keywords to use in my search cos to be sincere am so confused.

I have a customized error 404 page that is specified in my web.config as shown below:

VB
<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="404" />
  <error statusCode="404" path="/derrors/404.aspx" responseMode="ExecuteURL" />
  <remove statusCode="500" />
  <error statusCode="500" path="/derrors/500.aspx" responseMode="ExecuteURL" />
</httpErrors>


While in my codebehind, I have this:

VB
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Server.ClearError()
    Response.TrySkipIisCustomErrors = True 'for IIS 7 integrated pipeine
    Response.Status = "404 Not Found"
    Response.StatusCode = 404
End Sub

This is working fine. But, there seems to be a problem that I could not solve so I decided to ask other gurus for help.

Now, here is the problem am facing: On the custom 404.aspx, I have a LinkButton whose click event fire the redirection code as below:

VB
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles LinkButton1.Click
    Response.RedirectToRoute("welcome")


End Sub

So, take for instance the site login page as: example.com/login, and mistakenly, the person typed example.com/logn. The user will be redirected to Error 404: Page Not Found exactly as I wanted.


But this LinkButton1 when clicked, will redirect to something like example.com/logn?404%3bhttps%3a%2f%2fwww.example.com%3a443%2flogn

What am I doing wrong here.

Please kindly help

What I have tried:

I have searched the net, yet no good result
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900