草庐IT

cookie_value

全部标签

c# - CodeContracts : Boolean condition evaluates to a constant value, 为什么?

我收到此警告但无法找出问题...CodeContracts:warning:TheBooleanconditiond1.Count!=d2.Countalwaysevaluatestoaconstantvalue.Ifit(oritsnegation)appearinthesourcecode,youmayhavesomedeadcodeorredundantcheck代码如下:publicstaticboolDictionaryEquals(IDictionaryd1,IDictionaryd2){if(d1==d2)returntrue;if(d1==null||d2==null)

c# - 管理 Application Insights Cookie

我想知道应用程序洞察力如何与cookie一起使用,因为我想了解用户和session跟踪,所以我一直在研究并...这里简单介绍一下这个理论:WheneverApplicationInsightsSDKgetarequestthatdoesn’thaveapplicationinsightsusertrackingcookie(setbyApplicationInsightsJSsnippet)itwillsetthiscookieandstartanewsession.(fromapmtips)2.UserTelemetryInitializerupdatestheIdandAcquis

c# - 在 Linq-To-Sql 中避免 "Nullable object must have a value."

我有一个这样的方法查询:publicIListGetBusinessObject(Guid?filterId){using(vardb=newL2SDataContext()){varresult=fromboindb.BusinessObjectswhere(filterId.HasValue)?bo.Filter==filterId.value:trueorderbybo.NameselectSqlModelConverters.ConvertBusinessObject(bo);returnresult.ToList();}}在运行时,这会抛出一个System.InvalidOp

c# - GetMonthName : Valid values are between 1 and 13, 包括在内。为什么?

我不小心将0传递给DateTimeFormatInfo的GetMonthName方法:DateTimeFormatInfoinfo=newDateTimeFormatInfo();varmonthName=info.GetMonthName(0);并得到一个System.ArgumentOutOfRangeException错误消息:有效值在1到13之间,包括在内。传入1到12将返回“January”到“December”,但传入13将返回一个空字符串。我明白为什么月份数字不是零索引的,但是第13个月是做什么用的? 最佳答案 这是因

c# - 如何删除 CookieContainer 中 1 个域下的 cookie

在System.Net.CookieContainer中如果我想删除某个域名下的所有cookies,怎么办? 最佳答案 你可以这样做。CookieContainerc=newCookieContainer();varcookies=c.GetCookies(newUri("http://www.google.com"));foreach(Cookiecoincookies){co.Expires=DateTime.Now.Subtract(TimeSpan.FromDays(1));}这将使您指定域的所有cookie过期。

c# - 将 DBNull.Value 和空文本框值传递给数据库

这个问题在这里已经有了答案:HowdoIParameterizeanullstringwithDBNull.Valueclearlyandquickly(8个答案)关闭8年前。我的页面上有一些文本框可以为空,因为它们是可选的,而且我有这个DAL代码parameters.Add(newSqlParameter("@FirstName",FirstName));parameters.Add(newSqlParameter("@LastName",LastName));parameters.Add(newSqlParameter("@DisplayName",DisplayName));pa

c# - 如何在 Web API 授权属性中获取请求 cookie?

在.NET中有两个AuthorizeAttribute类。一个在System.Web.Http命名空间中定义:namespaceSystem.Web.Http{//Summary://Specifiestheauthorizationfilterthatverifiestherequest'sSystem.Security.Principal.IPrincipal.[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method,Inherited=true,AllowMultiple=true)]publicclassAut

c# - 流利的断言 : Assert one OR another value

使用流畅的断言,我想断言给定的字符串包含两个字符串之一:actual.Should().Contain("oneWay").Or().Should().Contain("anotherWay");//eitervalueshouldpasstheassertion.//forexample:"youmaydoitoneWay."shouldpass,but//"youmaydoitthisWay."shouldnotpass只有当两个值都不包含时,断言才会失败。这不起作用(甚至无法编译),因为没有Or()运算符。我现在是这样做的:boolisVariant1=actual.Contai

c# - Asp.net 身份过期 session Cookie

我们正在使用MVC5.2和ASP.NETIdentity使用表单例份验证屏幕(用户和密码组合)进行身份验证的框架,并且使用cookie保留身份。我在身份框架的启动方法中进行了配置,将身份验证cookie的到期时间设置为30天,当用户选择“记住我”(IsPersistent=true)时,这很好用。当IsPersistent=false(用户选择不选择“记住我”)时,默认创建sessioncookie。此sessioncookie在InternetExplorer和FireFox中运行良好,当浏览器关闭时,cookie将丢失。在Chrome和Safari(可能还有其他浏览器)中,有一些选

c# - ASP.NET Core 2.0 预览版 1 : How to set up Cookie Authentication with custom login path

在ASP.NETCore2.0中,.UseAuthentication()中间件有一个重大更改,不再允许oldsyntaxmentionedhere去工作。新版本似乎在addAuthentication中处理配置,但我无法在任何地方找到任何关于如何更改指定自定义登录和注销url的旧代码的详细信息。services.AddAuthentication(o=>{//WherecanIspecifythis?????varopt=newCookieAuthenticationOptions(){LoginPath="/api/login",LogoutPath="/api/logout",}