Problem with cookies

Discussion in 'ASP .Net' started by Patxi, May 10, 2006.

  1. Patxi

    Patxi Guest

    This is the first time I try to use cookies, and despite of reading some
    tutotials, I'm have real trouble to make it work correctly. My cookie
    reading code is in Master Page. When I click on a test button (in a WEb
    User Control inside the aspx page), cookie value is displayed in Master
    Page but if I go to another page, no value is displayed...

    I need to be able tu use cookie's value across all the site... What am I
    doing wrong ?

    Code in WebUser control, this code on a button click event:

    8<---------------------

    HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    HttpContext.Current.Response.Cookies["TestValue"].Expires =
    DateTime.Today.AddDays(365);

    --------------------->8

    And this code in OnPreRender of my Master page:

    8<---------------------

    if (Request.Cookies["TestValue"] != null){
    litCookieTest.Text = Response.Cookies["TestValue"].Value;
    }else{
    litCookieTest.Text = Request.Cookies["TestValue"].Value;
    }
    --------------------->8
     
    Patxi, May 10, 2006
    #1
    1. Advertising

  2. Patxi

    MSDN Guest

    Patxi,

    If you put a breakpoint in the OnPreRender event handler does it get called
    all the time
    It is not called all the time. Is it due to caching??

    SA

    "Patxi" <> wrote in message
    news:4462471c$0$300$...
    > This is the first time I try to use cookies, and despite of reading some
    > tutotials, I'm have real trouble to make it work correctly. My cookie
    > reading code is in Master Page. When I click on a test button (in a WEb
    > User Control inside the aspx page), cookie value is displayed in Master
    > Page but if I go to another page, no value is displayed...
    >
    > I need to be able tu use cookie's value across all the site... What am I
    > doing wrong ?
    >
    > Code in WebUser control, this code on a button click event:
    >
    > 8<---------------------
    >
    > HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    > HttpContext.Current.Response.Cookies["TestValue"].Expires =
    > DateTime.Today.AddDays(365);
    >
    > --------------------->8
    >
    > And this code in OnPreRender of my Master page:
    >
    > 8<---------------------
    >
    > if (Request.Cookies["TestValue"] != null){
    > litCookieTest.Text = Response.Cookies["TestValue"].Value;
    > }else{
    > litCookieTest.Text = Request.Cookies["TestValue"].Value;
    > }
    > --------------------->8
     
    MSDN, May 10, 2006
    #2
    1. Advertising

  3. What is the value of mstrMyValue?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    Professional Numbskull

    Hard work is a medication for which
    there is no placebo.

    "MSDN" <> wrote in message
    news:...
    > Patxi,
    >
    > If you put a breakpoint in the OnPreRender event handler does it get
    > called all the time
    > It is not called all the time. Is it due to caching??
    >
    > SA
    >
    > "Patxi" <> wrote in message
    > news:4462471c$0$300$...
    >> This is the first time I try to use cookies, and despite of reading some
    >> tutotials, I'm have real trouble to make it work correctly. My cookie
    >> reading code is in Master Page. When I click on a test button (in a WEb
    >> User Control inside the aspx page), cookie value is displayed in Master
    >> Page but if I go to another page, no value is displayed...
    >>
    >> I need to be able tu use cookie's value across all the site... What am I
    >> doing wrong ?
    >>
    >> Code in WebUser control, this code on a button click event:
    >>
    >> 8<---------------------
    >>
    >> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >> DateTime.Today.AddDays(365);
    >>
    >> --------------------->8
    >>
    >> And this code in OnPreRender of my Master page:
    >>
    >> 8<---------------------
    >>
    >> if (Request.Cookies["TestValue"] != null){
    >> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >> }else{
    >> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >> }
    >> --------------------->8

    >
    >
     
    Kevin Spencer, May 10, 2006
    #3
  4. Patxi

    Dumbell Guest

    Kevin,

    Even if mstrMyValue = "SomeValue" it still does not work
    the Cookie value is lost between pages.

    Thanks

    B

    "Kevin Spencer" <> wrote in message
    news:...
    > What is the value of mstrMyValue?
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > Professional Numbskull
    >
    > Hard work is a medication for which
    > there is no placebo.
    >
    > "MSDN" <> wrote in message
    > news:...
    >> Patxi,
    >>
    >> If you put a breakpoint in the OnPreRender event handler does it get
    >> called all the time
    >> It is not called all the time. Is it due to caching??
    >>
    >> SA
    >>
    >> "Patxi" <> wrote in message
    >> news:4462471c$0$300$...
    >>> This is the first time I try to use cookies, and despite of reading some
    >>> tutotials, I'm have real trouble to make it work correctly. My cookie
    >>> reading code is in Master Page. When I click on a test button (in a WEb
    >>> User Control inside the aspx page), cookie value is displayed in Master
    >>> Page but if I go to another page, no value is displayed...
    >>>
    >>> I need to be able tu use cookie's value across all the site... What am I
    >>> doing wrong ?
    >>>
    >>> Code in WebUser control, this code on a button click event:
    >>>
    >>> 8<---------------------
    >>>
    >>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>> DateTime.Today.AddDays(365);
    >>>
    >>> --------------------->8
    >>>
    >>> And this code in OnPreRender of my Master page:
    >>>
    >>> 8<---------------------
    >>>
    >>> if (Request.Cookies["TestValue"] != null){
    >>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>> }else{
    >>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>> }
    >>> --------------------->8

    >>
    >>

    >
    >
     
    Dumbell, May 11, 2006
    #4
  5. Patxi

    Patxi Guest

    I have no chache settings...

    MSDN wrote:
    > Patxi,
    >
    > If you put a breakpoint in the OnPreRender event handler does it get called
    > all the time
    > It is not called all the time. Is it due to caching??
    >
    > SA
    >
    > "Patxi" <> wrote in message
    > news:4462471c$0$300$...
    >> This is the first time I try to use cookies, and despite of reading some
    >> tutotials, I'm have real trouble to make it work correctly. My cookie
    >> reading code is in Master Page. When I click on a test button (in a WEb
    >> User Control inside the aspx page), cookie value is displayed in Master
    >> Page but if I go to another page, no value is displayed...
    >>
    >> I need to be able tu use cookie's value across all the site... What am I
    >> doing wrong ?
    >>
    >> Code in WebUser control, this code on a button click event:
    >>
    >> 8<---------------------
    >>
    >> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >> DateTime.Today.AddDays(365);
    >>
    >> --------------------->8
    >>
    >> And this code in OnPreRender of my Master page:
    >>
    >> 8<---------------------
    >>
    >> if (Request.Cookies["TestValue"] != null){
    >> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >> }else{
    >> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >> }
    >> --------------------->8

    >
    >
     
    Patxi, May 11, 2006
    #5
  6. Patxi

    Patxi Guest

    My main problem is that I set cookie's value in Default.aspx, and when I
    refresh the page or visit another page, I'm unable to retreive
    cookie's value...

    I think that cookie is only saved between pages refresh instead of
    having a 'site' cookie...

    I really try to applicate tutorials, but I think I'm missing something...

    Dumbell wrote:
    > Kevin,
    >
    > Even if mstrMyValue = "SomeValue" it still does not work
    > the Cookie value is lost between pages.
    >
    > Thanks
    >
    > B
    >
    > "Kevin Spencer" <> wrote in message
    > news:...
    >> What is the value of mstrMyValue?
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> Professional Numbskull
    >>
    >> Hard work is a medication for which
    >> there is no placebo.
    >>
    >> "MSDN" <> wrote in message
    >> news:...
    >>> Patxi,
    >>>
    >>> If you put a breakpoint in the OnPreRender event handler does it get
    >>> called all the time
    >>> It is not called all the time. Is it due to caching??
    >>>
    >>> SA
    >>>
    >>> "Patxi" <> wrote in message
    >>> news:4462471c$0$300$...
    >>>> This is the first time I try to use cookies, and despite of reading some
    >>>> tutotials, I'm have real trouble to make it work correctly. My cookie
    >>>> reading code is in Master Page. When I click on a test button (in a WEb
    >>>> User Control inside the aspx page), cookie value is displayed in Master
    >>>> Page but if I go to another page, no value is displayed...
    >>>>
    >>>> I need to be able tu use cookie's value across all the site... What am I
    >>>> doing wrong ?
    >>>>
    >>>> Code in WebUser control, this code on a button click event:
    >>>>
    >>>> 8<---------------------
    >>>>
    >>>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>> DateTime.Today.AddDays(365);
    >>>>
    >>>> --------------------->8
    >>>>
    >>>> And this code in OnPreRender of my Master page:
    >>>>
    >>>> 8<---------------------
    >>>>
    >>>> if (Request.Cookies["TestValue"] != null){
    >>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>> }else{
    >>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>> }
    >>>> --------------------->8
    >>>

    >>

    >
    >
     
    Patxi, May 11, 2006
    #6
  7. Patxi

    MSDN Guest

    This is very strange I am having the same problem you are having using your
    example.
    it seems that the cookie is saved for a specific page and not the entire
    website.
    I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
    WebServer with PORT NUMBER etc...
    So I moved the sample I have to a web site and the same thing is happening.
    The cookie does not have to persist.
    Still looking for an answer.

    SA

    "Patxi" <> wrote in message
    news:4462c6f5$0$296$...
    >I have no chache settings...
    >
    > MSDN wrote:
    >> Patxi,
    >>
    >> If you put a breakpoint in the OnPreRender event handler does it get
    >> called all the time
    >> It is not called all the time. Is it due to caching??
    >>
    >> SA
    >>
    >> "Patxi" <> wrote in message
    >> news:4462471c$0$300$...
    >>> This is the first time I try to use cookies, and despite of reading some
    >>> tutotials, I'm have real trouble to make it work correctly. My cookie
    >>> reading code is in Master Page. When I click on a test button (in a WEb
    >>> User Control inside the aspx page), cookie value is displayed in Master
    >>> Page but if I go to another page, no value is displayed...
    >>>
    >>> I need to be able tu use cookie's value across all the site... What am I
    >>> doing wrong ?
    >>>
    >>> Code in WebUser control, this code on a button click event:
    >>>
    >>> 8<---------------------
    >>>
    >>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>> DateTime.Today.AddDays(365);
    >>>
    >>> --------------------->8
    >>>
    >>> And this code in OnPreRender of my Master page:
    >>>
    >>> 8<---------------------
    >>>
    >>> if (Request.Cookies["TestValue"] != null){
    >>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>> }else{
    >>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>> }
    >>> --------------------->8

    >>
     
    MSDN, May 11, 2006
    #7
  8. Patxi

    Patxi Guest

    For the record, I'm using an IIS virtual directory, running IIS 5.0...

    MSDN wrote:
    > This is very strange I am having the same problem you are having using your
    > example.
    > it seems that the cookie is saved for a specific page and not the entire
    > website.
    > I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
    > WebServer with PORT NUMBER etc...
    > So I moved the sample I have to a web site and the same thing is happening.
    > The cookie does not have to persist.
    > Still looking for an answer.
    >
    > SA
    >
    > "Patxi" <> wrote in message
    > news:4462c6f5$0$296$...
    >> I have no chache settings...
    >>
    >> MSDN wrote:
    >>> Patxi,
    >>>
    >>> If you put a breakpoint in the OnPreRender event handler does it get
    >>> called all the time
    >>> It is not called all the time. Is it due to caching??
    >>>
    >>> SA
    >>>
    >>> "Patxi" <> wrote in message
    >>> news:4462471c$0$300$...
    >>>> This is the first time I try to use cookies, and despite of reading some
    >>>> tutotials, I'm have real trouble to make it work correctly. My cookie
    >>>> reading code is in Master Page. When I click on a test button (in a WEb
    >>>> User Control inside the aspx page), cookie value is displayed in Master
    >>>> Page but if I go to another page, no value is displayed...
    >>>>
    >>>> I need to be able tu use cookie's value across all the site... What am I
    >>>> doing wrong ?
    >>>>
    >>>> Code in WebUser control, this code on a button click event:
    >>>>
    >>>> 8<---------------------
    >>>>
    >>>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>> DateTime.Today.AddDays(365);
    >>>>
    >>>> --------------------->8
    >>>>
    >>>> And this code in OnPreRender of my Master page:
    >>>>
    >>>> 8<---------------------
    >>>>
    >>>> if (Request.Cookies["TestValue"] != null){
    >>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>> }else{
    >>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>> }
    >>>> --------------------->8

    >
     
    Patxi, May 11, 2006
    #8
  9. Patxi

    MSDN Guest

    Patxi,

    Have you tired this without master page?
    I am using IIS 5.1, Win XP Pro

    SA

    "Patxi" <> wrote in message
    news:446364f6$0$281$...
    > For the record, I'm using an IIS virtual directory, running IIS 5.0...
    >
    > MSDN wrote:
    >> This is very strange I am having the same problem you are having using
    >> your example.
    >> it seems that the cookie is saved for a specific page and not the entire
    >> website.
    >> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
    >> WebServer with PORT NUMBER etc...
    >> So I moved the sample I have to a web site and the same thing is
    >> happening.
    >> The cookie does not have to persist.
    >> Still looking for an answer.
    >>
    >> SA
    >>
    >> "Patxi" <> wrote in message
    >> news:4462c6f5$0$296$...
    >>> I have no chache settings...
    >>>
    >>> MSDN wrote:
    >>>> Patxi,
    >>>>
    >>>> If you put a breakpoint in the OnPreRender event handler does it get
    >>>> called all the time
    >>>> It is not called all the time. Is it due to caching??
    >>>>
    >>>> SA
    >>>>
    >>>> "Patxi" <> wrote in message
    >>>> news:4462471c$0$300$...
    >>>>> This is the first time I try to use cookies, and despite of reading
    >>>>> some tutotials, I'm have real trouble to make it work correctly. My
    >>>>> cookie reading code is in Master Page. When I click on a test button
    >>>>> (in a WEb User Control inside the aspx page), cookie value is
    >>>>> displayed in Master Page but if I go to another page, no value is
    >>>>> displayed...
    >>>>>
    >>>>> I need to be able tu use cookie's value across all the site... What am
    >>>>> I doing wrong ?
    >>>>>
    >>>>> Code in WebUser control, this code on a button click event:
    >>>>>
    >>>>> 8<---------------------
    >>>>>
    >>>>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>>> DateTime.Today.AddDays(365);
    >>>>>
    >>>>> --------------------->8
    >>>>>
    >>>>> And this code in OnPreRender of my Master page:
    >>>>>
    >>>>> 8<---------------------
    >>>>>
    >>>>> if (Request.Cookies["TestValue"] != null){
    >>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>>> }else{
    >>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>>> }
    >>>>> --------------------->8

    >>
     
    MSDN, May 11, 2006
    #9
  10. Patxi

    Patxi Guest

    I stopped trying it, I'm trying Profile system... But I have a big
    problem, since it works against SQL and I'm developping a 3 tier
    application, so I would like to use my BLL or a single XML file to store
    profiles, but I'm unable to find an implemention in XML...

    I'm studying
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASPNETProvMod_Prt5.asp
    but I can't find a more realistic example of xml driven
    ProfileProvider... Can you point me to a more practical site ?

    Thanks

    MSDN wrote:
    > Patxi,
    >
    > Have you tired this without master page?
    > I am using IIS 5.1, Win XP Pro
    >
    > SA
    >
    > "Patxi" <> wrote in message
    > news:446364f6$0$281$...
    >> For the record, I'm using an IIS virtual directory, running IIS 5.0...
    >>
    >> MSDN wrote:
    >>> This is very strange I am having the same problem you are having using
    >>> your example.
    >>> it seems that the cookie is saved for a specific page and not the entire
    >>> website.
    >>> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
    >>> WebServer with PORT NUMBER etc...
    >>> So I moved the sample I have to a web site and the same thing is
    >>> happening.
    >>> The cookie does not have to persist.
    >>> Still looking for an answer.
    >>>
    >>> SA
    >>>
    >>> "Patxi" <> wrote in message
    >>> news:4462c6f5$0$296$...
    >>>> I have no chache settings...
    >>>>
    >>>> MSDN wrote:
    >>>>> Patxi,
    >>>>>
    >>>>> If you put a breakpoint in the OnPreRender event handler does it get
    >>>>> called all the time
    >>>>> It is not called all the time. Is it due to caching??
    >>>>>
    >>>>> SA
    >>>>>
    >>>>> "Patxi" <> wrote in message
    >>>>> news:4462471c$0$300$...
    >>>>>> This is the first time I try to use cookies, and despite of reading
    >>>>>> some tutotials, I'm have real trouble to make it work correctly. My
    >>>>>> cookie reading code is in Master Page. When I click on a test button
    >>>>>> (in a WEb User Control inside the aspx page), cookie value is
    >>>>>> displayed in Master Page but if I go to another page, no value is
    >>>>>> displayed...
    >>>>>>
    >>>>>> I need to be able tu use cookie's value across all the site... What am
    >>>>>> I doing wrong ?
    >>>>>>
    >>>>>> Code in WebUser control, this code on a button click event:
    >>>>>>
    >>>>>> 8<---------------------
    >>>>>>
    >>>>>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>>>> DateTime.Today.AddDays(365);
    >>>>>>
    >>>>>> --------------------->8
    >>>>>>
    >>>>>> And this code in OnPreRender of my Master page:
    >>>>>>
    >>>>>> 8<---------------------
    >>>>>>
    >>>>>> if (Request.Cookies["TestValue"] != null){
    >>>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>>>> }else{
    >>>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>>>> }
    >>>>>> --------------------->8

    >
    >
     
    Patxi, May 11, 2006
    #10
  11. Patxi

    Patxi Guest

    Incredible !!!

    I'm testing with Profile and I'm having the same problem...

    I create a Web User control (ProfileViewer.ascx) with a label, and this
    code in the Page_Load event:

    Label1.Text = Profile.FirstName;

    I have another Web User control (ProfileSetCtrl.ascx) with a button and
    this code on button's click event:

    Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)

    In my Default.aspx file, I scan for jpgs in a directory and load one
    ProfileSetCtrl.ascx per jpg, passing the jpg file path...

    I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
    value configured in Web.config displayed...

    I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...

    What am I missing ?

    Thanks

    MSDN wrote:
    > Patxi,
    >
    > Have you tired this without master page?
    > I am using IIS 5.1, Win XP Pro
    >
    > SA
    >
    > "Patxi" <> wrote in message
    > news:446364f6$0$281$...
    >> For the record, I'm using an IIS virtual directory, running IIS 5.0...
    >>
    >> MSDN wrote:
    >>> This is very strange I am having the same problem you are having using
    >>> your example.
    >>> it seems that the cookie is saved for a specific page and not the entire
    >>> website.
    >>> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
    >>> WebServer with PORT NUMBER etc...
    >>> So I moved the sample I have to a web site and the same thing is
    >>> happening.
    >>> The cookie does not have to persist.
    >>> Still looking for an answer.
    >>>
    >>> SA
    >>>
    >>> "Patxi" <> wrote in message
    >>> news:4462c6f5$0$296$...
    >>>> I have no chache settings...
    >>>>
    >>>> MSDN wrote:
    >>>>> Patxi,
    >>>>>
    >>>>> If you put a breakpoint in the OnPreRender event handler does it get
    >>>>> called all the time
    >>>>> It is not called all the time. Is it due to caching??
    >>>>>
    >>>>> SA
    >>>>>
    >>>>> "Patxi" <> wrote in message
    >>>>> news:4462471c$0$300$...
    >>>>>> This is the first time I try to use cookies, and despite of reading
    >>>>>> some tutotials, I'm have real trouble to make it work correctly. My
    >>>>>> cookie reading code is in Master Page. When I click on a test button
    >>>>>> (in a WEb User Control inside the aspx page), cookie value is
    >>>>>> displayed in Master Page but if I go to another page, no value is
    >>>>>> displayed...
    >>>>>>
    >>>>>> I need to be able tu use cookie's value across all the site... What am
    >>>>>> I doing wrong ?
    >>>>>>
    >>>>>> Code in WebUser control, this code on a button click event:
    >>>>>>
    >>>>>> 8<---------------------
    >>>>>>
    >>>>>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
    >>>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>>>> DateTime.Today.AddDays(365);
    >>>>>>
    >>>>>> --------------------->8
    >>>>>>
    >>>>>> And this code in OnPreRender of my Master page:
    >>>>>>
    >>>>>> 8<---------------------
    >>>>>>
    >>>>>> if (Request.Cookies["TestValue"] != null){
    >>>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>>>> }else{
    >>>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>>>> }
    >>>>>> --------------------->8

    >
    >
     
    Patxi, May 11, 2006
    #11
  12. Patxi

    MSDN Guest

    This is extremely frustration for me also I have no Idea
    It seems no one else is reading this at all

    May be bring this question back to the top of the list and lets start over
    again.

    Sorry...

    SA


    "Patxi" <> wrote in message
    news:44639f0c$0$291$...
    > Incredible !!!
    >
    > I'm testing with Profile and I'm having the same problem...
    >
    > I create a Web User control (ProfileViewer.ascx) with a label, and this
    > code in the Page_Load event:
    >
    > Label1.Text = Profile.FirstName;
    >
    > I have another Web User control (ProfileSetCtrl.ascx) with a button and
    > this code on button's click event:
    >
    > Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)
    >
    > In my Default.aspx file, I scan for jpgs in a directory and load one
    > ProfileSetCtrl.ascx per jpg, passing the jpg file path...
    >
    > I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
    > value configured in Web.config displayed...
    >
    > I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...
    >
    > What am I missing ?
    >
    > Thanks
    >
    > MSDN wrote:
    >> Patxi,
    >>
    >> Have you tired this without master page?
    >> I am using IIS 5.1, Win XP Pro
    >>
    >> SA
    >>
    >> "Patxi" <> wrote in message
    >> news:446364f6$0$281$...
    >>> For the record, I'm using an IIS virtual directory, running IIS 5.0...
    >>>
    >>> MSDN wrote:
    >>>> This is very strange I am having the same problem you are having using
    >>>> your example.
    >>>> it seems that the cookie is saved for a specific page and not the
    >>>> entire website.
    >>>> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and
    >>>> the WebServer with PORT NUMBER etc...
    >>>> So I moved the sample I have to a web site and the same thing is
    >>>> happening.
    >>>> The cookie does not have to persist.
    >>>> Still looking for an answer.
    >>>>
    >>>> SA
    >>>>
    >>>> "Patxi" <> wrote in message
    >>>> news:4462c6f5$0$296$...
    >>>>> I have no chache settings...
    >>>>>
    >>>>> MSDN wrote:
    >>>>>> Patxi,
    >>>>>>
    >>>>>> If you put a breakpoint in the OnPreRender event handler does it get
    >>>>>> called all the time
    >>>>>> It is not called all the time. Is it due to caching??
    >>>>>>
    >>>>>> SA
    >>>>>>
    >>>>>> "Patxi" <> wrote in message
    >>>>>> news:4462471c$0$300$...
    >>>>>>> This is the first time I try to use cookies, and despite of reading
    >>>>>>> some tutotials, I'm have real trouble to make it work correctly. My
    >>>>>>> cookie reading code is in Master Page. When I click on a test
    >>>>>>> button (in a WEb User Control inside the aspx page), cookie value is
    >>>>>>> displayed in Master Page but if I go to another page, no value is
    >>>>>>> displayed...
    >>>>>>>
    >>>>>>> I need to be able tu use cookie's value across all the site... What
    >>>>>>> am I doing wrong ?
    >>>>>>>
    >>>>>>> Code in WebUser control, this code on a button click event:
    >>>>>>>
    >>>>>>> 8<---------------------
    >>>>>>>
    >>>>>>> HttpContext.Current.Response.Cookies["TestValue"].Value =
    >>>>>>> mstrMyValue;
    >>>>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>>>>> DateTime.Today.AddDays(365);
    >>>>>>>
    >>>>>>> --------------------->8
    >>>>>>>
    >>>>>>> And this code in OnPreRender of my Master page:
    >>>>>>>
    >>>>>>> 8<---------------------
    >>>>>>>
    >>>>>>> if (Request.Cookies["TestValue"] != null){
    >>>>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>>>>> }else{
    >>>>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>>>>> }
    >>>>>>> --------------------->8

    >>
     
    MSDN, May 11, 2006
    #12
  13. Patxi

    Patxi Guest

    I solved it adding this:

    this.Context.Response.Redirect(this.Context.Request.Url.ToString());

    after setting profile's value...

    MSDN wrote:
    > This is extremely frustration for me also I have no Idea
    > It seems no one else is reading this at all
    >
    > May be bring this question back to the top of the list and lets start over
    > again.
    >
    > Sorry...
    >
    > SA
    >
    >
    > "Patxi" <> wrote in message
    > news:44639f0c$0$291$...
    >> Incredible !!!
    >>
    >> I'm testing with Profile and I'm having the same problem...
    >>
    >> I create a Web User control (ProfileViewer.ascx) with a label, and this
    >> code in the Page_Load event:
    >>
    >> Label1.Text = Profile.FirstName;
    >>
    >> I have another Web User control (ProfileSetCtrl.ascx) with a button and
    >> this code on button's click event:
    >>
    >> Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)
    >>
    >> In my Default.aspx file, I scan for jpgs in a directory and load one
    >> ProfileSetCtrl.ascx per jpg, passing the jpg file path...
    >>
    >> I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
    >> value configured in Web.config displayed...
    >>
    >> I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...
    >>
    >> What am I missing ?
    >>
    >> Thanks
    >>
    >> MSDN wrote:
    >>> Patxi,
    >>>
    >>> Have you tired this without master page?
    >>> I am using IIS 5.1, Win XP Pro
    >>>
    >>> SA
    >>>
    >>> "Patxi" <> wrote in message
    >>> news:446364f6$0$281$...
    >>>> For the record, I'm using an IIS virtual directory, running IIS 5.0...
    >>>>
    >>>> MSDN wrote:
    >>>>> This is very strange I am having the same problem you are having using
    >>>>> your example.
    >>>>> it seems that the cookie is saved for a specific page and not the
    >>>>> entire website.
    >>>>> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and
    >>>>> the WebServer with PORT NUMBER etc...
    >>>>> So I moved the sample I have to a web site and the same thing is
    >>>>> happening.
    >>>>> The cookie does not have to persist.
    >>>>> Still looking for an answer.
    >>>>>
    >>>>> SA
    >>>>>
    >>>>> "Patxi" <> wrote in message
    >>>>> news:4462c6f5$0$296$...
    >>>>>> I have no chache settings...
    >>>>>>
    >>>>>> MSDN wrote:
    >>>>>>> Patxi,
    >>>>>>>
    >>>>>>> If you put a breakpoint in the OnPreRender event handler does it get
    >>>>>>> called all the time
    >>>>>>> It is not called all the time. Is it due to caching??
    >>>>>>>
    >>>>>>> SA
    >>>>>>>
    >>>>>>> "Patxi" <> wrote in message
    >>>>>>> news:4462471c$0$300$...
    >>>>>>>> This is the first time I try to use cookies, and despite of reading
    >>>>>>>> some tutotials, I'm have real trouble to make it work correctly. My
    >>>>>>>> cookie reading code is in Master Page. When I click on a test
    >>>>>>>> button (in a WEb User Control inside the aspx page), cookie value is
    >>>>>>>> displayed in Master Page but if I go to another page, no value is
    >>>>>>>> displayed...
    >>>>>>>>
    >>>>>>>> I need to be able tu use cookie's value across all the site... What
    >>>>>>>> am I doing wrong ?
    >>>>>>>>
    >>>>>>>> Code in WebUser control, this code on a button click event:
    >>>>>>>>
    >>>>>>>> 8<---------------------
    >>>>>>>>
    >>>>>>>> HttpContext.Current.Response.Cookies["TestValue"].Value =
    >>>>>>>> mstrMyValue;
    >>>>>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
    >>>>>>>> DateTime.Today.AddDays(365);
    >>>>>>>>
    >>>>>>>> --------------------->8
    >>>>>>>>
    >>>>>>>> And this code in OnPreRender of my Master page:
    >>>>>>>>
    >>>>>>>> 8<---------------------
    >>>>>>>>
    >>>>>>>> if (Request.Cookies["TestValue"] != null){
    >>>>>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
    >>>>>>>> }else{
    >>>>>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
    >>>>>>>> }
    >>>>>>>> --------------------->8

    >
     
    Patxi, May 12, 2006
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,571
    Hans Kesting
    Feb 3, 2005
  2. Andy Fish
    Replies:
    3
    Views:
    6,578
    Fredrik Lindner
    Nov 6, 2003
  3. user
    Replies:
    3
    Views:
    686
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 31, 2007
  4. archana
    Replies:
    1
    Views:
    525
  5. _Who
    Replies:
    7
    Views:
    2,747
Loading...

Share This Page