增加后台功能

This commit is contained in:
2018-04-15 23:30:15 +08:00
parent 8f92efaf7b
commit 42335efe55
1118 changed files with 296710 additions and 4 deletions
+59
View File
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace COMCMS.Common
{
/// <summary>
/// Cookies 帮助类
/// </summary>
public class CookiesHelper
{
#region 获取Cookies
/// <summary>
/// 读cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <returns>cookie值</returns>
public static string GetCookie(string strName)
{
if (MyHttpContext.Current.Request.Cookies != null && MyHttpContext.Current.Request.Cookies[strName] != null)
return HttpUtility.UrlDecode(MyHttpContext.Current.Request.Cookies[strName].ToString());
return "";
}
#endregion
#region 写入Cookies
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
/// <param name="expires">过期时间(分钟)</param>
public static void WriteCookie(string strName, string strValue, int expires)
{
CookieOptions op = new CookieOptions
{
Expires = DateTime.Now.AddMinutes(expires),
Path = "/",
HttpOnly = true
};
MyHttpContext.Current.Response.Cookies.Append(strName, strValue, op);//用户名
}
#endregion
#region 清除Cookies
/// <summary>
/// 移除Cookies
/// </summary>
/// <param name="strKey"></param>
public static void ClearCookies(string strKey)
{
MyHttpContext.Current.Response.Cookies.Delete(strKey);
}
#endregion
}
}