草庐IT

set_cookie

全部标签

c# - 将 'Set Next Statement' 强制为 'if' block 时出现 CLR System.NullReferenceException

背景我承认这不是正常代码执行期间可能发生的事情,但我在调试时发现了它,并认为它很有趣,可以分享。我认为这是由JIT编译器引起的,但欢迎任何进一步的想法。我已经使用VS2013复制了这个针对4.5和4.5.1框架的问题:设置要查看此异常,必须启用CommonLanguageRuntimeExceptions:DEBUG>异常...我已将问题的原因提炼为以下示例:usingSystem.Collections.Generic;usingSystem.Linq;namespaceConsoleApplication6{publicclassProgram{staticvoidMain(){v

c# - 如何在用户本地时间设置 cookie 过期时间?

我想要一个cookie在10分钟内准确过期(只是为了争论)。如果我使用Expires=DateTime.Now.AddMinutes(30)并且用户落后我3小时,cookie将在收到后立即过期(这是正确的吗?)如何设置到期时间以使其对用户而言是本地的?当然,我可以使用JavaScript将信息与请求一起发送,或者使用某种JS库在客户端创建cookie,或者保留用户配置文件并询问用户时区,但我正在寻找懒人解决方案。 最佳答案 cookie过期日期将以GMT时间结束,因此您的代码将简单地工作。

c# - ASP.NET MVC : Problem setting the Authorize attribute Role from a variable, 需要常量

我在设置变量的授权属性角色值时遇到问题。错误消息说它需要一个const变量。当我创建一个const类型变量时,它工作正常,但我试图从Web.Config文件或任何其他允许最终用户设置它的文件加载值。我正在使用集成的Windows身份验证,因为这是一个仅限Intranet的应用程序。有没有办法从Controller检查用户角色?我将在if语句中使用它而不是属性来进行身份验证。[Authorize(Roles=Config.GMPUser)]publicActionResultIndex(){returnView();} 最佳答案 我有

c# - Asp.Net MVC 6 Cookie 身份验证 - 授权失败

我正在尝试使用CookieMiddleware创建asp.netcoremvc6应用程序验证。我的代码编译没有错误,但即使在成功登录后我也不是授权用户这是我的startup.cs配置app.UseCookieAuthentication(options=>{options.AuthenticationScheme="CookieAuth";options.LoginPath=newPathString("/Account/Login/");options.AccessDeniedPath=newPathString("/Account/Login/");options.Automati

c# - Properties.Settings.Default.Save(); ->那个文件在哪里

我有一个使用“设置”的应用。要保存我使用的设置:Properties.Settings.Default.Save();阅读我使用的:Properties.Settings.Default.MyCustomSetting;在我的应用程序文件夹中,我只有exe文件。没有配置文件。我的应用程序运行良好,可以读写设置。如果该文件不在应用程序文件夹中,该文件位于何处? 最佳答案 在我的WindowsXP机器上,设置保存在C:\DocumentsandSettings\\ApplicationData\下某处名为user.config的文件中。

c# - 为什么 EPPlus 告诉我 "Can' t set color when patterntype is not set"当我设置了 PatternType 时?

我有这段代码来尝试设置标题行的样式:worksheet.Cells["A32:D32"].Style.Font.Name="Georgia";worksheet.Cells["A32:D32"].Style.Font.Bold=true;worksheet.Cells["A32:D32"].Style.Font.Size=16;worksheet.Cells["A32:D32"].Style.Fill.PatternType=ExcelFillStyle.Solid;worksheet.Cells["A32:D33"].Style.Fill.BackgroundColor.SetCol

c# - 如何在设计时避免 XAML 代码中出现 "object reference not set to an instance of an object"异常?

我自己设计的wpf用户控件有问题。问题是,当我在我的程序中实现用户控件时,在设计时XAML代码中出现objectreferencenotsettoaninstanceofanobject异常。设计师向我展示了以下信息:atMicrosoft.Expression.Platform.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Typetype,BooleansupportInternal)atMicrosoft.Expression.Platform.InstanceBuilders.ClrObjectInstan

c# - 创建 Cookie ASP.NET 和 MVC

我有一个很简单的问题。我想在客户端创建一个由服务器创建的cookie。我发现了很多pages描述,如何使用它-但我总是停留在同一个点上。我有一个DBController,它会在有对数据库的请求时被调用。DBController的构造函数是这样的:publicclassDBController:Controller{publicDBController(){HttpCookieStudentCookies=newHttpCookie("StudentCookies");StudentCookies.Value="hallo";StudentCookies.Expires=DateTime

c# - 如何为数组数据成员定义 get 和 set?

我正在创建一个类Customer,它具有以下数据成员和属性:privatestringcustomerName;privatedouble[]totalPurchasesLastThreeDays;//arrayof3elementsthatwillholdthetotalsofhowmuchthecustomerpurchasedforthepastthreedaysi.e.element[0]=100,element[1]=50,element[2]=250publicstringCustomerName{get{returncustomerName;}set{customerNa

c# - System.StackOverflowException ,何时使用 get set 属性?

在wcfserviceLibrary.DLL中发生类型为“System.StackOverflowException”的未处理异常代码如下。[DataContract]publicclassmemberdesignations{[DataMember]publicstringDesigId{get{returnDesigId;}set{DesigId=value;}}[DataMember]publicstringDesignationName{get{returnDesignationName;}set{DesignationName=value;}}}然后我有如下的Typememb