.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Cookies and postbacks

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net


I wonder if anyone can help me understand the following.

If I have a click event that updates Session, I know that I cannot access the updated session value until the prerender event because of the page lifecycle.  However this is not the same with cookies.

I changed a variable that was stored in Session to be stored in a cookie.  The same sequence of events occurred - click - get current value - update value - store new value.  In this case is was revaking a cookie.  If I then access the cookie again at prerender the cookie value hasn't changed.

Can anyone in the know please explain why this is?



View Complete Post

More Related Resource Links


Keen Explanation About Cookies

Cookies and Helpers


The api guide is real briefe about cookies. I would I go about creating/assiging a cookie, setting exporation, and anything else...

Could someone just list out the helper capabilities?

Thanks for your time...!

postbacks and url rewriting


Hi all,

I am using Intelligencia url rewriter for my project and have run in a small problem. I have a regular expression like

<rewrite url="~/(.+)/(.+)/(.+).aspx" to="~/Article.aspx?a=$3&amp;s=$2&amp;p=$1"/>

so a page request like

/parent/category/articlename.aspx is interpreted as /Article.aspx?a=articlename&s=category&p=parent.

This above is all fine, but now when I do a postback (a login block), it picks up the url /Article.aspx?a=articlename&s=category&p=parent and interprets as /Article.aspx?a=article&s=category&p=parent.

Now, how can I make sure that on the postback, it still throws back the original url /parent/category/articlename.aspx so that the url is properly interpreted?


how read write cookies in asp.net


hi please give me code for read write cookies in  asp.net



where save my cookies


hi frieds

here i have code for write cookies in computer but i dont know where is store in local pc , i know it write some where b'caz i can read this cookies also but where it save in local pc

here is code

                           'Create a new cookie, passing the name into the constructor
                            Dim ContactId As New HttpCookie("ContactID")
                            Dim PWDID As New HttpCookie("PWDID")
                            'Set the cookies value
                            ContactId.Value = Session("MemberLoginID") ' EMailField

Flash player doesn't send cookies while requesting an aspx page



 I'm developing a web-site, that uses SWFUpload for multiple files upload to the server. Page, that uploades files, is accessable only to registered user. Authentication is done via web-forms (authentication mode="Forms" in Web.config). Flash uploades files to special web page - upload.aspx. In IE everything works great, but Flash player in non-IE browser (in Firefox, for example) does not send any cookies to upload.aspx. Because of it no sesion and no authentication information is available in this page.

 I can pass all the information, necessary for uploading, in GET-parameters, which upload.aspx recieve. But this is a serious security hole and I don't want to expose session information. I can pass session identifier in GET-request. But the question is the following: how can I restore session information from the session identifier? How can I make HttpContext.Current.User point to currently logged in user in this case?

Any help will be appreciated.

Keep "collapsed" state of CollapsiblePanelExtender between postbacks



I have created a UserControl with a CollapsiblePanelExtender inside. In my Web page, I have a PlaceHolder in which many UserControls are added dynamically at every PostBack.

Everytime my page reloads, the CollapsiblePanelExtenders are expanded, even if they were collapsed before the PostBack. Is there a way to keep track of the "collapsed" state of the CollapsiblePanelExtender ? It seems hard since there is no server event triggered when the panel is collapsed / expanded.

Someone seemed to have the same problem here : http://forums.asp.net/p/1094970/1650425.aspx. I tried his solution (accessing the ClientState of the CollapsiblePanelExtenders using Request.Form) but my values are always null or true, even if the CollapsiblePanel is collapsed before PostBack.

Here is some piece of code :

AUMBlock block = (AUMBlock)Page.LoadControl("AUMBlock.ascx");
//CollapsiblePanelExtender cpe = (CollapsiblePanelExtender)block.FindControl("cpe");
//string clientState = cpe.ClientState;

3rd party cookies, proxies, and you.

I have an intranet site that is used to pull several other intranet applications/tools and database info to one place.One of the most popular features uses iFrames and jQuery tabs to give a broad overview of activities, signal etc in a network node.  Chrome and Firefox eat it up with no problems, IE will work if you override the cookie policies that restrict 3rd party cookies without a valid p3p (what a worthless standard).  IE also works if you already authenticated yourself on the individual sites and the session cookies are still valid.It's gaining popularity outside the original small intended audience, and I can't expect everyone to override their privacy settings or expect IT to push the sites out to exception lists on all PCs in the company.Before someone chimes in with "just add protected void Application_BeginRequest(object sender, EventArgs e) { HttpContext.Current.Response.AppendHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""); } to your global .asax", I have ZERO control of the child site., so regular 'ol p3p settings ain't gonna cut it.After wasting over two days with it and getting behind on more important matters, I figure my options at this point areSomehow inject p3p into the header of the child site just before iFrame renders. (uhggnh)someh

Local Cookies Storage, HttpWebRequest and HttpWebResponse

How to work with it? How way to place cookies retrieved from HttpWebResponse to the local Cookies storage? Please show me example

Where are cookies stored for Forms Authentication when debugging asp.net from VS and the asp.net dev

Hey all!   When I have my app-deployed on a server and login with forms authentication I see my cookie get's created in   C:\Users\<user>\AppData\Roaming\Microsoft\Windows\CookiesAnd it works great and everything!But when I run my application locally with the asp.net development server while debugging from Visual Studio, I NEVER see a cookie file get created in that location.   I'm using the same PC and the same version of internet explorer 8 on the production as I am development so I'm not sure what's going on here.   Does anyone know where cookies get stored when hitting http://localhost:<devport> ?

Page cannot be found error on clearing cookies while running application

Hello all,            I've a web application which is running on sql state session .. And is running well under normal conditions. But when my application is in home page or landing page after loging to the application, if user clears all his history and cookies and click on any menu in the application . It is giving  Internet Explorer cannot display the webpage error.. I'm not able to debug the error.. am getting the same problem even under deploying conditions. How to handle this issue?   Thanks in advance, Hari.

Language problem cookies in the Arab language

Language problem cookies in the Arab language upload my project to server , I discovered that when you save data[Values] in cookies, we find  (  Request.Cookies["test"].Values["val"] -----> ?????)  in that the symbols =????? 

Help with Cookies

Hello all,please I'm working in vb language and I would like to know how to store the values of asp.net controls (textboxes, selected items of combo boxes etc) so that I will be able to display them on a different page. I was using cookies but it's not working.Page 1Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click      Response.Cookies("FirstName").Value = txtFirstName.Text.ToString()      Response.cookies("Date").value = cboDate.selectedItem.Text.ToString()      Response.Cookies("FirstName").Expires = DateTime.Now.AddDays(1)      Response.Cookies("Date").Expires = DateTime.Now.AddDays(1)End Subpage 3Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init       If Not Request.Cookies("FirstName") Is Nothing Then            lblName.Text = Server.HtmlEncode(Request.Cookies("FirstName").Value)           lblDate.Text = Server.HtmlEncode(Request.Cookies("Date").Value)                 End IfEnd SubI will be gr

General Question About Remembering Property Values Between Postbacks

Here are examples of two different ways I've found to story Property values between postbacks:    private bool Initialized    {      get      {        return Convert.ToBoolean(this.Attributes["Initialized"]);      }      set      {        this.Attributes["Initialized"] = value.ToString();      }    }    private int DataTableRowIndex    {      get      {        return (int)ViewState["DataTableRowIndex"];      }      set      {        ViewState["DataTableRowIndex"] = value;      }    }I'd appreciate any comments about differences between these two approaches [Attributes vs. ViewState].  Is one better or worse?Robert

How to Pass a Grid an EF Object and have it edit/update etc. without postbacks until save?

Hey all.Here's what I'm trying to do:I want to pull an EF object, or create a new one. Pass it to javascript (jquery or some such) and then have the grid bind on the client side and do everything client side from that point forward. (edits, validation etc.) Once complete, I want jquery to push back via a pagemethod or web service or whatever, the updated EF object so that i can persist it.Reason?I need a highly scalable architecture that handles not storing objects in the session or posting to a database when they haven't been saved to a user. I know I can do this with Silverlight, however given MS's less than convincing comments about Silverlight's future vs HTML 5, I'm strongly leaning towards asp.net or mvc.net if I can come up with a way to use jquery (or even a 3rd party control that does this!) to handle all of the data editing, updating etc. for a master/child display (i.e. Invoice) without the server having to store it and without having to use the viewstate.Ideas?In my mind this would be the holly grail. Render the page, push the data to the controls, have the controls do their thing until save without ever doing server processing, and then on save, push back the object and allow the server to persist it (and probably do server validation before presisting it just in case). By doing this you could make superscalable apps that

UpdatePanel in .Net 4 - Causing Full Page Postbacks

Hi Guys,I've just updated a website from 3.5 to 4.0 and I've noticed that paging controls and command buttons in update panels cause full page postbacks (where they never use to in my 3.5 version).Any ideas why this might be?Cheers,Andrew
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend