Advertisement

04.07.2008 at 02:46PM PDT, ID: 23302907
[x]
Attachment Details

Creating Cookie in the Master Page of C# Application

Asked by sonu19 in Programming for ASP.NET, Miscellaneous Web Development, C# Programming Language

Tags: Microsoft, c#

Hey Guys,

I am calling a funtions in master page to create cookie
the function looks like this
    public void savecookie(string cookiename, string cookievalue, string cookieexp)
    {
        HttpCookie cookie = new HttpCookie(cookiename);
        cookie.Value = cookievalue;
        cookie.Expires.AddDays(Convert.ToDouble(cookieexp));
        Response.Cookies.Add(cookie);
    }

The call looks like this
mast.savecookie("zipcodecook", zipcode.Text.ToString(), "10");

I continue to get this error
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 74:         cookie.Value = cookievalue;
Line 75:         cookie.Expires.AddDays(Convert.ToDouble(cookieexp));
Line 76:         Response.Cookies.Add(cookie);
Line 77:     }
Line 78:     #endregion
 

If I create a cookie on the page it works finr just not in the master page code file it doesn't

Start Free Trial
 
Loading Advertisement...
 
[+][-]04.07.2008 at 03:29PM PDT, ID: 21301103

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.08.2008 at 11:35AM PDT, ID: 21308191

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.11.2008 at 12:22PM PDT, ID: 21337324

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Miscellaneous Web Development, C# Programming Language
Tags: Microsoft, c#
Sign Up Now!
Solution Provided By: RDdice
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628