Cookie中文乱码

yangchun1213 yangchun1213 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/// <summary>
/// Set Cookies
/// </summary>
/// <param name="iMinutes">Cookie Expired Minutes</param>
/// <returns>true if the cookie was successfully added; false otherwise.</returns>
public static bool SetCookies(string Key, string Value, int iMinutes)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[Key];
if (cookie == null)
{
cookie = new HttpCookie(Key, Value);
//cookie.Domain = "/";
}
else
{
cookie.Value = Value;
}
cookie.Expires = DateTime.Now.AddMinutes(iMinutes);
System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
System.Web.HttpContext.Current.Request.Cookies.Add(cookie);
return true;
}

/// <summary>
/// Get Coolies string Value, null if no this cookie.
/// </summary>
/// <param name="Key">Cookie Name</param>
public static string GetCookies(string Key)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[Key];
if (cookie != null)
{
return cookie.Value;
}
else
{
return null;
}
}

登录页面在本地VS里浏览不会出乱码,但发布到iis里就会出中文乱码,搜索了很多这样的情况,但都是没有解决这问题,请大虾帮忙,急~~~~~~~~~~~~
...全文
评论 15
收藏 已收藏
分享
返回顶部
yangchun1213
.NET社区 62,273 成员 668,968 内容