Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Response.Redirect for a beginner

I'm a beginner in a web server side class. I need to post my homework and the text box for the link for the teacher is too short. He suggested I use some code to redirect to the correct page. So, I created a page called r.asp that simply says <%Response.Redirect = "HomeworkProgress/homeworkProgress.asp"%> but it doesn't work. r.asp is in the root directory. The page I need the user to get to is in the directory HomeworkProgress which is in the root directory. Then the page is homeworkProgress.asp. So then I added <%Response.Buffer = true%> to the top, since my book said this may be important to use with the Response.Redirect method. It still doesn't work. What am I doing wrong? Thanks, Suzy

Comments

  • vanithvanith Posts: 44Member
    : I'm a beginner in a web server side class. I need to post my homework and the text box for the link for the teacher is too short. He suggested I use some code to redirect to the correct page. So, I created a page called r.asp that simply says <%Response.Redirect = "HomeworkProgress/homeworkProgress.asp"%> but it doesn't work. r.asp is in the root directory. The page I need the user to get to is in the directory HomeworkProgress which is in the root directory. Then the page is homeworkProgress.asp. So then I added <%Response.Buffer = true%> to the top, since my book said this may be important to use with the Response.Redirect method. It still doesn't work. What am I doing wrong? Thanks, Suzy
    :

    Hi Suzy!

    Welcome to ASP coding...
    Response.Redirect is a method (or a subroutine). You are trying to assign a string value to a method which is wrong. You pass the URL as a parameter to the method, as below.
    <%
    dim sURL
    sURL = "HomeworkProgress/homeworkProgress.asp"
    Response.Redirect(sURL)
    %>

    The above code will instruct your client's browser to redirect from the current page to "homeworkProgress.asp" located in "HomeworkProgress" directory, present in the location as that of your current page.

    Coming to Response.Buffer
    Response.Buffer is a property which when set to TRUE, will buffer page output. That is the server will not send any output from the current page to the client until either Response.Flush or Response.End method is called.
    In the other case, whenever you use Response.write or just the simple text outside your <%%> tags, the text is sent as HTML to the browser. In this case, when you try to redirect after sending some text to the client, you will get an error something like "Response headers already sent to the browser". To avoid this, we use Response.Buffer = true at the beginning of your script.

    Happy coding!

    :)heers,
    Vanith
Sign In or Register to comment.