ホームページをご覧になるには、最初にスプラッシュランディングページ(ENTER SITE)default-splash.aspx
にアクセスする必要があります。なぜ私のbool HttpCookieがスプラッシュページにリダイレクトしても正しく動作しないのですか?
同様に、見た人はそれを無視して、default.aspx
のホームページにとどまります。
bool userVisited = false;
HttpCookie cookie = Request.Cookies["Hoarding"];
if (cookie == null)
{
cookie = new HttpCookie("Hoarding");
cookie.Values.Add("userVisitedSplash", true);
cookie.Expires = DateTime.Now.Days(1);
cookie.HttpOnly = true;
this.Page.Response.AppendCookie(cookie);
} else{
userVisited = cookie.Values["userVisitedSplash"];
}
if(userVisited){
Response.Redirect("/default.aspx");
} else{
Response.Redirect("/default-splash.aspx");
}
私はライン上で、しかしエラーが発生します。
cookie.Values.Add("userVisitedSplash", true);
CS1502: 'System.Collections.Specialized.NameValueCollection.Add(文字列、文字列)' の最良のオーバーロードされたメソッドの試合を
ありがとう@Izzy!しかし、今私は: '暗黙のうちにタイプ '文字列'を 'bool'に変換することはできません:userVisited = cookie.Values [" userVisitedSplash "];' – davvv