Click here to Skip to main content
14,971,754 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:

<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" />

While in my codebehind, I have this:

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    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:

Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles LinkButton1.Click

End Sub

So, take for instance the site login page as:, and mistakenly, the person typed 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

What am I doing wrong here.

Please kindly help

What I have tried:

I have searched the net, yet no good result

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