[2005] Response.AppendHeader not working correctly.
I create a brand new Web Site project.Open default aspx page and in Page_Load event I add:
Code:
Response.AppendHeader("Refresh", "10")
Now when my page is displayed I view source, and nothing, zip, nowt...this value has not been added :(
Any ideas?
Woof
Re: [2005] Response.AppendHeader not working correctly.
HTTP headers aren't part of the source code; they're sent before the response body.
You may be thinking of the http-equiv metatag. This allows the effect of certain headers to be achieved by placing them in the HTML code. Either way works, however the pure HTTP method is neater, since that's where headers are supposed to go in the first place.
Re: [2005] Response.AppendHeader not working correctly.
Hmmm I have had this working in 2003 using the above code. There are many web sites that say this is what I am supposed to use:
http://www.extremeexperts.com/Net/Ar...onTimeout.aspx
I want to make my page refresh 5 seconds after the session timeout, so that it forces the user back to the login page.
I have had this working about 6 months back in 2003, but cannot seem to get it working on 2005 where I am now.
Any ideas what I'm doing wrong?
Woka
PS I have had a bad week, it's like I have forgotten everything I have learnt over the last 10 years. Someone should strip me of my MVP :) hehe
Re: [2005] Response.AppendHeader not working correctly.
You need to add the URL.
Code:
Response.AppendHeader(
"Refresh",
(Session.Timeout * 60 + 5) + @"; URL=http://example.com/wherever"
);
If you've done that/it doesn't work, post the code you used.
Re: [2005] Response.AppendHeader not working correctly.
That's what used to work, and I have been trying all day.
My code is:
Code:
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.AppendHeader("Refresh", (Session.Timeout * 60 + 5).ToString & "; URL=http://example.com/wherever")
End Sub
End Class
Yet still nothing in the source :(
Woof
Re: [2005] Response.AppendHeader not working correctly.
Still, that would be in the response header, not the html source.
Use fiddler (free) to inspect the headers:
http://www.fiddlertool.com/fiddler/
Re: [2005] Response.AppendHeader not working correctly.
Hmmmm ok.
I am crap.
In saying it didn't work, what I meant was it didnt show up in the html source, which is what I was expecting.
But during testing, this works a treat, refreshes my page and because my forms authentication has timed out it redirects me to the login page. I then login and it redirects me to the page I was on b4 it timed out.
I was in too much of a rush and was expecting things in the source without really testing it. In fact, if I had my testing properly there would not have been a need for this thread.
bad woka *SLAP*
Thanks for you time and help :)
Wooof