Setting Cookie Port

Posted by MasterMax1313 on Stack Overflow See other posts from Stack Overflow or by MasterMax1313
Published on 2010-03-09T02:31:24Z Indexed on 2010/03/09 2:36 UTC
Read the original article Hit count: 316

Filed under:

I'm trying to set the port on a cookie in ASP.NET (code below), but I'm getting a very unusual error at runtime (below the code). Any thoughts?

target.Cookie = new Cookie
{
    Comment = "Test Comment",
    CommentUri = new System.Uri("http://www.tempuri.org"),
    Discard = false,
    Domain = "tempuri.com",
    Expired = false,
    Expires = new DateTime(2015, 12, 31),
    HttpOnly = false,
    Name = "TestCookie",
    Path = "/",
    Port = "443",
    Secure = false,
    Value = "Test Value",
    Version = 1,
};

Exception:

System.Net.CookieException: The 'Port'='443' part of the cookie is invalid..

© Stack Overflow or respective owner

Related posts about .net-3.5