-
Mar 3rd, 2011, 01:32 PM
#1
Thread Starter
Lively Member
deleting temp internet files
Hi everybody
I had a page to update user picture and redirect user to login page, the problem is when a user re-login, the old picture is still available until user refresh the page.
notes: I have already use <%@ output> but not working with master page
and also have used Response.Cache.SetCacheability(HttpCacheability.NoCache) and also not working
here is my code:
Code:
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
'Updating User Pic
fuUserPic.PostedFile.SaveAs(Server.MapPath("~\Images\UserPic\" & UserID & ".jpg"))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage("msg=Please login again")
End Sub
please what can I do to delete temp internet files to display picture after updating?
-
Mar 3rd, 2011, 11:23 PM
#2
Re: deleting temp internet files
Try this one
Response.CacheControl = "no-cache";
Response.Expires = -1;
response.ExpiresAbsolute = new DateTime(1900, 1, 1);
response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AppendHeader("Pragma", "no-cache");
Response.AppendHeader("Cache-Control", "no-cache");
Please mark you thread resolved using the Thread Tools as shown
-
Mar 4th, 2011, 11:33 AM
#3
Thread Starter
Lively Member
Re: deleting temp internet files
thank you danasegarane for help
but the problem not working.
bintaleb
-
Mar 6th, 2011, 05:50 AM
#4
Re: deleting temp internet files
Hello,
Is it possible that you can show us the complete code and markup for the whole page(s)?
Gary
-
Mar 7th, 2011, 05:31 AM
#5
Thread Starter
Lively Member
Re: deleting temp internet files
Hi all
markup and code:
Code:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="test.aspx.vb" Inherits="CubeEval.test" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
CssClass="failureNotification" ValidationGroup="UpdateButton" />
</div>
<div>
</div>
<div>
<div>
<asp:Label ID="lblUpload" runat="server"></asp:Label>
</div>
<div>
<asp:FileUpload ID="fuUserPic" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="fuUserPic" Display="Dynamic"
ErrorMessage="jpg or JPG Image extention." SetFocusOnError="True"
ToolTip="jpg or JPG Image extention." ValidationExpression="^.+(.jpg|.JPG)$"
ValidationGroup="UpdateButton" CssClass="failureNotification">*</asp:RegularExpressionValidator>
<asp:CustomValidator ID="CustomValidator2" runat="server"
ControlToValidate="fuUserPic" ErrorMessage="Uplaoed file should be less than 5 kb."
ValidationGroup="UpdateButton" CssClass="failureNotification" OnServerValidate="CheckUploadedFile"
Display="Dynamic" SetFocusOnError="True"
ToolTip="Uplaoed file should be less than 5 kb." >*</asp:CustomValidator>
</div>
</div>
<div>
<asp:Button ID="btnUpdate" runat="server"
Text="<%$ Resources:Default, Update %>" ValidationGroup="UpdateButton" />
</div>
</div>
</asp:Content>
Code:
Public Class UpdateUserProfile
Inherits BasePage
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
'Updating User Pic
fuUserPic.PostedFile.SaveAs(Server.MapPath("~\Images\UserPic\" & UserID & ".jpg"))
'Response.CacheControl = "no-cache"
'Response.Expires = -1
'Response.ExpiresAbsolute = New DateTime(1900, 1, 1)
'Response.Cache.SetCacheability(HttpCacheability.NoCache)
'Response.AppendHeader("Pragma", "no-cache")
'Response.AppendHeader("Cache-Control", "no-cache")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage("msg=Please login again")
End Sub
Protected Sub CheckUploadedFile(ByVal sender As Object, ByVal args As ServerValidateEventArgs) Handles CustomValidator2.ServerValidate
If fuUserPic.FileBytes.Length < 5000 Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
End Class
-
Mar 7th, 2011, 05:49 AM
#6
PowerPoster
Re: deleting temp internet files
i think u are setting no cache in the wrong place. you are doing it on button click. it should be done on Page_Load:
Code:
Public Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetAllowResponseInBrowserHistory(False)
End If
End Sub
I'm just guessing here
-
Mar 7th, 2011, 11:34 AM
#7
Re: deleting temp internet files
I think Nitesh could be onto something here.
I take it you "want" to use Caching though, is that correct? Or, are you looking into caching to try to fix a problem?
Gary
-
Mar 11th, 2011, 06:58 AM
#8
Thread Starter
Lively Member
Re: deleting temp internet files
sorry to being late
the problem still have not been solved
I want to clean Caching to be able to display new picture.
bintaleb
-
Mar 12th, 2011, 12:04 PM
#9
Re: deleting temp internet files
Hello,
My question was really aimed at whether you actually "need" caching at all? What benefit is it serving in this instance? Can you not simply remove the caching altogether?
Gary
-
Mar 14th, 2011, 09:04 AM
#10
Thread Starter
Lively Member
Re: deleting temp internet files
Originally Posted by gep13
Hello,
My question was really aimed at whether you actually "need" caching at all? What benefit is it serving in this instance? Can you not simply remove the caching altogether?
Gary
Hello
please forget that idea to clean caching, I explain my problem in the beginning after updating user picture and re-login the user can't see the new picture which has been updated except refresh the page.
may be I was thinking the problem will be solved when I clean the caching.
bintaleb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|