【发布时间】:2021-08-04 15:22:40
【问题描述】:
我正在尝试从 Asp.net Core 中的静态类访问 Cookie,到目前为止,我在 Google 上找不到任何有用的主题。有什么建议吗?
我已经在 asp.net 中做到了:
public static string GetString(string Key)
{
var format = System.Web.HttpContext.Current.Request.Cookies["Language"];
if (format == null)
format = new HttpCookie("Language") { Value = "Fa" };
ResourceManager rm = new ResourceManager("Ippv.Virtual.Application.Properties." + format.Value,
Assembly.GetExecutingAssembly());
return rm.GetString(Key);
}
如何在 asp.net core 中编写等效的代码?
【问题讨论】:
-
显示一些相关代码会有所帮助。为什么不能将cookie值作为参数传递给静态方法?
标签: c# asp.net-core cookies