Results 1 to 10 of 10

Thread: deleting temp internet files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    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 <&#37;@ 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?

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    Re: deleting temp internet files

    thank you danasegarane for help

    but the problem not working.

    bintaleb

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    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

  6. #6
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    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

  7. #7
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    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

  9. #9
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    97

    Re: deleting temp internet files

    Quote Originally Posted by gep13 View Post
    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
  •  



Click Here to Expand Forum to Full Width