Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


URL redirection issue

URL redirection issue

URL redirection issue


How would I identify a URL redirection error that needs correcting in my code, please? I can't see anything in my Visual Studio code or when I press F12 online - the relevant page is here: www.dimadayoub.net/contact.aspx

I have not come across this error before (server error 301?) and am not even sure what I am looking for.

The problem I have is that when the form is completed and 'Send' is pressed, the user is not redirected to my thankyou.aspx page. The email code is never actually processed due to the URL redirection error, and so www.dimadayoub.net/contact.aspx remains in the address bar. That is what I need to correct.

Do I need to change my Web.config file in any way? I am in the dark about this error.


RE: URL redirection issue


What is your redirection code so we can help troubleshoot? Response 301 can certainly stem from a redirection issue. Also, is this VB-related? I deal with a lot of PHP and SQL information, so I am assuming that header redirection is how you are processing this? I am not terribly familiar with ASP, but I am guessing that it is closely related somehow. :) Hopefully we can help narrow down any issue.

Also, if it is of any value to you, I submitted a test entry on the URL you provided and it did not present the error to me. It simply routed me back to the same page.

RE: URL redirection issue

Thanks for your reply, Pixel God.

Yes, you don't actually get any error when you click on send but the problem is what you have identified: it routed you back to the same page and not to the thank you page. That's because it's 'stuck' due to the redirection back to the contact form page.

Yes, it is vb.net related but I don't think the issue it directly related to vb.net - not to the code.

The redirection code I have is this:

CODE -->

Dim target = String.Format("~/thankyou.aspx?your_name={0}", yourname)

        Response.Redirect(String.Format("~/thankyou.aspx?your_name={0}", yourname), True) 

But as I say, that is not even read because the browser does not leave the contact page. None of the SMTP code (tested and fine) is processed. I am not sure what you mean by 'header redirection' but various online tutorials do refer to that.

RE: URL redirection issue

Looking at the HTML/Javascript for the page this is what I see happening.

1. User fills out form and hits submit
2. Javascript validation runs - if successful form is processed (a quick glance seems that validation may be off - perhaps for testing purposes)
3. The form data is submitted to "contact.aspx" - the same page that is hosting the form (the "action" attribute of the form element).

So as far as I can see there is no redirection occurring anywhere (unless it is happening within the contact.aspx server side code. (I filled out the form to attempt to log any redirects, but the fake email I used triggered an aspx SmtpException "Sending address not accepted due to spam filter")

RE: URL redirection issue

Could you post the code in the Send button's event handler, and/or and methods that may get called when Send is clicked? That's where you should have the Response.Redirect by the way, in the event handler for the Send button.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: URL redirection issue

Many thanks to you both for your replies.

I am not sure where the SmtpException has come from! It's not part of the code that I have done! There is no validation or Captcha at the moment. I just wanted to ensure the form could be sent before going further with it. Yes, the server side code (vb.net) should redirect the user - please see below.

CODE -->


<asp:Button ID="contact_submitted" runat="server" name="contact_submitted" type="submit" Text="Send" OnClick="contact_submitted_Click" />


Protected Sub contact_submitted_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles contact_submitted.Click

        SMTP code here

        myMessage = Nothing
        Smtpserver = Nothing

        Dim target = String.Format("~/thankyou.aspx?your_name={0}", yourname)

        Response.Redirect(String.Format("~/thankyou.aspx?your_name={0}", yourname), True)

    End Sub 

As I say, this is probably not even read because as soon as the 'Send' button is pressed the form data is submitted to contact.aspx and not to thankyou.aspx, but I can't see what is causing that to happen. If I can't see it in Visual Studio or in F12 online (it's temporarily down), how would I identify an erroneous redirect so that I can correct it?

Thanks again to you both.

RE: URL redirection issue


From what I gather, Response.Redirect will result in an HTTP error if headers have already been sent. Does HttpResponse.BufferOutput return anything of value that may help you pinpoint where the error is occurring? Sorry if I am approaching this due to my vague understanding of ASP, but perhaps a different perspective may help. :)

RE: URL redirection issue

Hello PixelGod

Thanks again.

Yes, any different perspective is welcome.

No errors are generated.

In my contact form page, where would I place HttpResponse.BufferOutput?


RE: URL redirection issue


I would assume that you put it in your contact.aspx.vb file after the Redirect code in this format:


Response.Redirect(String.Format("~/thankyou.aspx?your_name={0}", yourname), True)

HttpResponse.BufferOutput = True 

With any luck it will dump any information regarding what the page is having issues with when processing the redirection out to your screen. Should help with any troubleshooting. Another suggestion I scrambled-up after searching the web was:


Response.Redirect(String.Format("~/thankyou.aspx?your_name={0}", yourname), True)


Taken from How to use Response Redirect in a server script, it seems that the code is never actually sent unless this tid-bit is placed in the code! I hope this helps. :)

RE: URL redirection issue

Hello Pixel God

That sounds promising.

Please give me a short while, I will try it, and get back to you.

Thanks again!

RE: URL redirection issue

I have delayed replying because I am waiting for a response from my Web hosting service.

I slimmed down my project and uploaded it again. I am now getting the message that you got:

SmtpException "Sending address not accepted due to spam filter"

Hopefully, that means the URL redirect problem has disappeared!

RE: URL redirection issue

Great news! Make sure you follow-up with what fixed your issue so if anyone else stumbles across this forum looking-up the same issue they can get pointed in the right direction for the fix.

RE: URL redirection issue

OK, it's now resolved.

I greatly simplified the project by deleting files in Solution Explorer (files relating to Twitter, Register.aspx, Login.aspx, etc) that my project does not use at the moment. I presume I can add them later if I wish?). ONce I had done that, the URL redirect problem disappeared.

I also needed to 'register' the Webmaster's email address (the recipient of the contact form's email) in what my Web hosting service calls a safe/white area of my Email programme (SmarterMail?). I had no idea about it!

What I have to do now is resolve how to display, and get working, Google's reCaptcha. I didn't want to do that until I knew that the email could be processed correctly (the reCaptcha would have just complicated things).

Many thanks again to you all for your help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close