设置Cookie选项

问题描述 投票:0回答:1

创建简单的方法,似乎'cookieOptions'函数无法正常工作,我正在获取其参考先决条件。

我可以知道需要导入什么引用或模块才能启用此功能

这里是示例方法:

public void SetCookie(string key, string value, int? expireTime)
{
    CookieOptions option = new CookieOptions(); /// => Missing reference here      
}

这是返回的错误:

'CookieOptions' could not be found (are you missing a using directive or an assembly reference?)

任何建议/评论TIA

c# setcookie
1个回答
0
投票

我假设是网络核心

命名空间:Microsoft.AspNetCore.Http部件:Microsoft.AspNetCore.Http.Features.dll

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.cookieoptions?view=aspnetcore-3.0

© www.soinside.com 2019 - 2024. All rights reserved.