Click here to Skip to main content
15,916,215 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Navigation in frameset Pin
nikhil123413-Aug-08 3:26
nikhil123413-Aug-08 3:26 
AnswerRe: Navigation in frameset Pin
Manas Bhardwaj13-Aug-08 4:12
professionalManas Bhardwaj13-Aug-08 4:12 
QuestionHow to stop Page being cached Pin
.NET- India 13-Aug-08 2:12
.NET- India 13-Aug-08 2:12 
AnswerRe: How to stop Page being cached Pin
SomeGuyThatIsMe13-Aug-08 2:20
SomeGuyThatIsMe13-Aug-08 2:20 
GeneralRe: How to stop Page being cached Pin
.NET- India 13-Aug-08 2:32
.NET- India 13-Aug-08 2:32 
GeneralRe: How to stop Page being cached Pin
SomeGuyThatIsMe13-Aug-08 2:42
SomeGuyThatIsMe13-Aug-08 2:42 
GeneralRe: How to stop Page being cached Pin
.NET- India 13-Aug-08 3:02
.NET- India 13-Aug-08 3:02 
GeneralRe: How to stop Page being cached Pin
SomeGuyThatIsMe13-Aug-08 3:11
SomeGuyThatIsMe13-Aug-08 3:11 
you have

if (!Page.IsPostBack)
{ 
Response.Buffer = true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

if (Session["UserName"] != null)
{
try
{
lblMsg.Text = Session["Type"].ToString()+" ("+ Session["UserName"].ToString()+")";
}
catch
{ 
Server.Transfer("../Admin/Default.aspx");
}
}
else
{
Server.Transfer("../Admin/Default.aspx");
}
}


correct? what you might try is

Response.Buffer = true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

if (Session["UserName"] != null && Session["Type"] != null)
{
lblMsg.Text = Session["Type"].ToString()+" ("+ Session["UserName"].ToString()+")";
}
else
{
Response.Redirect("../Admin/Default.aspx");
}


you only need to have type in the if statement if there is a chance it could be null whitout the UserName bieng null. notice that there is no if(!Page.IsPostBack) statement, this way the code will run EVERY postback, if the session times out and the user tries something they will be redirected to the login(i assume default.aspx is your login page, if its in the same directory as the current page you dont need the relative path just Default.aspx) the nocache options are always set so the back button is effectivly broken(provided they work correctly). this should work, but if the nocache part doesnt, try using meta tags instead.

Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

GeneralRe: How to stop Page being cached Pin
.NET- India 13-Aug-08 3:25
.NET- India 13-Aug-08 3:25 
GeneralRe: How to stop Page being cached Pin
SomeGuyThatIsMe13-Aug-08 3:34
SomeGuyThatIsMe13-Aug-08 3:34 
AnswerRe: How to stop Page being cached Pin
darkcalin13-Aug-08 3:46
darkcalin13-Aug-08 3:46 
GeneralRe: How to stop Page being cached Pin
.NET- India 13-Aug-08 19:24
.NET- India 13-Aug-08 19:24 
QuestionIssue in Uploading files using FileInfo Pin
saini arun13-Aug-08 1:51
saini arun13-Aug-08 1:51 
AnswerRe: Issue in Uploading files using FileInfo Pin
Manas Bhardwaj13-Aug-08 2:10
professionalManas Bhardwaj13-Aug-08 2:10 
Questionbound database field Pin
UD(IA)13-Aug-08 1:28
UD(IA)13-Aug-08 1:28 
AnswerRe: Edited question Pin
Christian Graus13-Aug-08 2:35
protectorChristian Graus13-Aug-08 2:35 
GeneralRe: Edited question Pin
UD(IA)13-Aug-08 2:43
UD(IA)13-Aug-08 2:43 
Questionproviding the final link in PROJECT NAME ??? [modified] Pin
Karan_TN13-Aug-08 1:20
Karan_TN13-Aug-08 1:20 
AnswerRe: providing the final link in PROJECT NAME ??? Pin
Anand Desai13-Aug-08 1:41
Anand Desai13-Aug-08 1:41 
GeneralRe: providing the final link in PROJECT NAME ??? Pin
Karan_TN13-Aug-08 2:06
Karan_TN13-Aug-08 2:06 
GeneralRe: providing the final link in PROJECT NAME ??? Pin
Manas Bhardwaj13-Aug-08 2:13
professionalManas Bhardwaj13-Aug-08 2:13 
GeneralRe: providing the final link in PROJECT NAME ??? Pin
Karan_TN13-Aug-08 2:19
Karan_TN13-Aug-08 2:19 
GeneralRe: providing the final link in PROJECT NAME ??? Pin
eyeseetee13-Aug-08 2:28
eyeseetee13-Aug-08 2:28 
Questionhow to add new rows at runtime in grid view control Pin
Member 465900113-Aug-08 0:57
Member 465900113-Aug-08 0:57 
AnswerRe: how to add new rows at runtime in grid view control Pin
Jörgen Andersson13-Aug-08 1:32
professionalJörgen Andersson13-Aug-08 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.