草庐IT

current_session_context_class

全部标签

c# - session 超时在 asp.net mvc 4 C# 中不起作用。为什么?

对于我的网站,我在web.config文件中配置了1周的登录session超时这是登录代码[AllowAnonymous][HttpPost]publicActionResultLogin(stringLogin,stringPassword){//emptypasswordsarenotallowedif(Password=="")returnRedirect(Request.UrlReferrer.ToString());boolLoginResult=WebSecurity.Login(Login,Password,true);returnRedirect(Request.Url

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - 用户 session 过期时如何重定向到页面?

我目前正在开发一个使用ASP.NET2.0框架的Web应用程序。当用户session到期时,我需要重定向到某个页面,比如SessionExpired.aspx。项目中有很多页面,因此将代码添加到站点的每个页面并不是一个好的解决方案。不过我有MasterPages,我认为这可能会有所帮助。谢谢! 最佳答案 您可以在global.asax的Session_Start事件中处理此问题。您可以在那里的请求中检查sessioncookie。如果sessioncookie存在,则session已过期:publicvoidSession_OnSt

c# - 通过反射仅获取当前类(class)成员

假设这段代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Reflection;namespaceTestFunctionality{classProgram{staticvoidMain(string[]args){//System.Reflection.Assembly.GetExecutingAssembly().LocationAssemblyassembly=Assembly.LoadF

c# - HttpContext.Current 如何在多线程环境中工作?

所以我想知道当(据我所知)asp.net是多线程时,asp.net究竟是如何能够限定静态属性的范围的。一种理论认为ASP.NET人员为每个请求维护一个不同的应用程序域......但这似乎不可行。另一种理论认为,.Current方法查看当前线程,然后使用它在某些哈希表(或其他静态存储机制)中查找http上下文。无论哪种方式,这都是一种看起来非常有用的技术......我想利用它,但绝对不想调试共享状态错误:-/ 最佳答案 它不是每个请求的AppDomain。如果你想使用线程特定的状态,尝试:[ThreadStatic]privatest

C#/N 休眠 : Association references unmapped class

几个小时以来,我一直在努力解决这个NHibernate问题。我在网络和NHibernate文档上进行了广泛的研究,但我无法理解这个问题。我对NHibernate比较陌生,但很喜欢它。不过,在那种情况下,它让我发疯。我正在为网站编写一个小型“投票”模块。我有几个类(Poll、PollVote和PollAnswer)。主要的Poll是导致问题的原因。这就是类的样子:publicclassPoll{publicvirtualintId{get;set;}publicvirtualSiteSite{get;set;}publicvirtualstringQuestion{get;set;}pu

c# - cs0030 :Unable to generate a temporary class

我有一个Web服务,当我尝试生成它的对象时出现以下错误。"Unabletogenerateatemporaryclass(result=1).errorCS0030:Cannotconverttype'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment[]'to'ShortSell.ShortSellRQOriginDestinationInformationFlightSegment'errorCS0030:Cannotconverttype'ShortSell.ShortSellRSOriginDestina

c# - NHibernate 无状态 session 的插入很慢

这几天我一直致力于改进NHibernateInsert性能。我在很多帖子(例如thisone)中读到,statelesssession可以每秒插入1000~2000条记录....然而,它可以插入1243条记录的最佳时间对我来说超过9秒:varsessionFactory=newNHibernateConfiguration().CreateSessionFactory();using(IStatelessSessionstatelessSession=sessionFactory.OpenStatelessSession()){statelessSession.SetBatchSize

c# - 如何知道 session 是否已设置

这个问题在这里已经有了答案:WhatisthebestwaytodetermineasessionvariableisnulloremptyinC#?(12个答案)关闭9年前。在我以前使用的php中session_start();if(isset(SESSION["user"])){//sessionisset}els{//thereisnosession}但是我在asp.net中这样做吗?我是说。哪些代码可以判断是否设置了session例如:ASP.NETC#//login.aspxSESSION["USER"];//user_profile.aspxif(SESSION["USER

c# - ASP.NET 5(核心): How to store objects in session-cache (ISession)?

我正在编写一个ASP.NET5MVC6(Core)应用程序。现在我需要在session缓存(ISession)中存储(设置和获取)一个对象。您可能知道,ISession的Set方法接受一个byte-array和Get-方法返回一个。在非核心应用程序中,我会使用BinaryFormatter来转换我的对象。但是我怎样才能在核心应用程序中做到这一点呢? 最佳答案 我会将对象序列化为JSON,并使用ISession上的扩展方法将它们保存为string。//Savevarkey="my-key";varstr=JsonConvert.Ser