Create Cookie ASP.NET & MVC : <p>I have a quite simple problem - I want to create a cookie at a Client, that is created by the server. 
I've found a lot of <a href="http://www.codeproject.com/Articles/244904/Cookies-in-ASP-NET" rel="noreferrer">pages</a> that describe, how to use it - but I always stuck at the same point.</p>

<p>I have a DBController that gets invoked when there is a request to the DB. </p>

<p>The DBController's constructor is like this:</p>

<pre><code>public class DBController : Controller
{
    public DBController()
    {
        HttpCookie StudentCookies = new HttpCookie("StudentCookies");
        StudentCookies.Value = "hallo";
        StudentCookies.Expires = DateTime.Now.AddHours(1);
        Response.Cookies.Add(StudentCookies);
        Response.Flush();
    }

    [... more code ...]

}
</code></pre>

<p>I get the Error "Object reference not set to an instance of an object" at:</p>

<pre><code>StudentCookies.Expire = DateTime.Now.AddHours(1)
</code></pre>

<p>This is a kind of a basic error message - so what kind of basic thing I've forgot?</p>
