使用asp.net/c#,怎么可能:
请注意,我将使用php设置cookie值。 请注意,html webform包含在代码中:
asp:Content ID =" webform" ContentPlaceHolderID =" WebForm1的" RUNAT ="服务器"
所以我需要一种方法来操作这个webform,这取决于我将在页面加载时读取的cookie值的设置
答案 0 :(得分:0)
if(!Page.IsPostback)
根据返回值response.redirect调用下面的方法到另一个页面。
private string GetCookieValue(string cookieName, string itemName)
{
var CookieName = "MY_COOKIE";
var CookieValue = string.empty;
HttpCookie myCookie = Request.Cookies[CookieName];
if (myCookie == null) return "No cookie found";
//If you added a key vs. the value in the cookie use this code
//CookieValue = myCookie[itemName].ToString();
//Get the value of the cookie if you are not using a key
CookieValue = myCookie.Value.ToString();
Return CookieValue;
}