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
Response.Status = "404 Not Found"
Response.StatusCode = 404
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
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