Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6825031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:58:23+00:00 2026-05-26T21:58:23+00:00

In ASP.net 2.0 Response.Cookies.Add() is a VOID (which boggles me somewhat). Is there a

  • 0

In ASP.net 2.0 Response.Cookies.Add() is a VOID (which boggles me somewhat). Is there a way to check to see if the function successfully added the cookie?

I just spent 2 hours trying to track down an authentication issue for one user. Finally I realized he was in a BUNCH of AD groups and I believe the cookie we were building for him, and trying to set, was > 4096 bytes.

Would be nice to know up front if the call to Response.Cookies.Add() failed.

We were trapping the error later in the global.asax page when we did:

 HttpCookie authCookie = Context.Request.Cookies[cookieName];

and authCookie for this user was always null.

Thanks for the responses.

I’ve decide to check the size before calling Response.Cookies.Add() and alert the user accordingly.

int iSize = System.Text.UTF8Encoding.UTF8.GetByteCount(authCookie.Values.ToString());
                if (iSize > 4096)
                {
                    lblMessage.Text = "The authentication cookie cannot be set as it is > 4096 bytes; a limit imposed by the browser.  The current size of the Cookie.Values is " + iSize.ToString() + " bytes.";
                    lblMessage.CssClass = "msgBox Alert";
                    return;
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:58:24+00:00Added an answer on May 26, 2026 at 9:58 pm

    I setup a simple project that write a random cookie value, and used Fiddler to examine the response:

    GET http://localhost.:2605/Default.aspx HTTP/1.1
    Accept: */*
    Accept-Language: en-us
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
    Accept-Encoding: gzip, deflate
    Connection: Keep-Alive
    Host: localhost.:2605
    Pragma: no-cache
    Cookie: ASP.NET_SessionId=wxpo32z2zxr1qlbwgx4on3z2; test1047139665=value775124204
    

    You can see the cookie in the Cookie section of the header above. This is consistent with the documentation at: http://msdn.microsoft.com/en-us/library/system.web.httpresponse.cookies.aspx

    The size limitation is documented here:

    http://support.microsoft.com/kb/306070

    Looks like you’ll have to check yourself before writing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since ASP.NET response filtering and post-cache substitution are not compatible, I need an alternative
I'm debugging an HttpModule with an ASP.NET response filter. This dynamically rewrites portions of
I have a server-sent events handler in ASP.NET Response.ContentType = text/event-stream; while (true) {
I would like to use standard ASP.NET file download response, like in other Stack
My asp.net application sending httpwebrequest to remote REST server and waiting for the response,
I am creating a web api using asp.net mvc4 and the response output is
If for instance, I was to give a response back to an ASP.Net Update
I am working with an asp.net 2.0 site (call it site 1) which has
ASP.Net has the concept of using 'subkeys' in cookies. i.e. You can write a
Im using asp.net 4.0 and Form auth. To check if a user is authenticated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.