I decided to rewrite the question because I found some information on how to accomplish the above:
http://msdn.microsoft.com/en-us/library/aa289495%28v=vs.71%29.aspx
However, my problem is that I am trying to do all this in an event Page_Load Login.aspx.cs.
At first it works fine until I try to log in by entering my credentials and clicking the "Login" button. Then all the infernal breaks are lost and I get an endless loop. It continues to navigate between download pages on Login.aspx.csand TestForCookies.aspx.cs. Every time a redirect URL grows with another one "?AcceptCookies=1. "Is there any work for this?
Code Login.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["AcceptsCookies"] == null)
{
Response.Cookies["TestCookie"].Value = "ok";
Response.Cookies["TestCookie"].Expires = DateTime.Now.AddMinutes(1);
Response.Redirect(BasePage.ResolveUrl("~/Common/TestForCookies.aspx?redirect=" + Server.UrlEncode(Request.Url.ToString())));
}
else
{
LoginBox.InstructionText = "Accept cookies = " + Request.QueryString["AcceptsCookies"];
}
}
}
Code TestForCookies.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
string redirect = Request.QueryString["redirect"];
string acceptsCookies = null;
if (Request.Cookies["TestCookie"] == null)
{
acceptsCookies = "0";
}
else
{
acceptsCookies = "1";
Response.Cookies["TestCookie"].Expires = DateTime.Now.AddDays(-1);
}
string url = redirect + "?AcceptsCookies=" + acceptsCookies;
Response.Redirect(url);
}