在本文中,我们将为您详细介绍asp.net-mvc–SessionStateTempDataProvider要求启用SessionState的相关知识,并且为您解答关于启用session的语句是的疑问
在本文中,我们将为您详细介绍asp.net-mvc – SessionStateTempDataProvider要求启用SessionState的相关知识,并且为您解答关于启用session的语句是的疑问,此外,我们还会提供一些关于 How To Set a NLS Session Parameter At Database Or Schema Level For All Connections?、.net core cookie 登录和 session 的 DataProtectionProvider 加入 redis、.net – 如何处理System.Data.DataTableExtensions.CopyToDataTable()中的缺陷、ASP.NET sessionState SQLServer模式超时不起作用的有用信息。
本文目录一览:- asp.net-mvc – SessionStateTempDataProvider要求启用SessionState(启用session的语句是)
- How To Set a NLS Session Parameter At Database Or Schema Level For All Connections?
- .net core cookie 登录和 session 的 DataProtectionProvider 加入 redis
- .net – 如何处理System.Data.DataTableExtensions.CopyToDataTable()中的缺陷
- ASP.NET sessionState SQLServer模式超时不起作用
asp.net-mvc – SessionStateTempDataProvider要求启用SessionState(启用session的语句是)
这个错误消息的奇怪之处在于我的web.config中的会话状态被设置为InProc,IIS7配置也显示它.
我正在运行一个经典的Web表单站点,只有一个小部分,我正在转移到MVC 1.0.现在我的常规网络表单default.aspx页面无法启动!
>我根本没有在MVC中使用TempData提供程序,所以我猜测框架确实出于某种原因但是,我的SesionState已启用…
>我的测试环境在集成模式的IIS 7上运行,我的webconfig使用sessionstate作为InProc并且工作正常.
更多信息:为了好玩,我创建了一个只有MVC的存根项目,并将其部署到测试环境,它工作正常! web.config基本上是相同的,一个工作,另一个不工作.
任何帮助表示赞赏.
错误信息
‘/’应用程序中的服务器错误.
SessionStateTempDataProvider要求启用SessionState.
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:system.invalidOperationException:SessionStateTempDataProvider要求启用SessionState.
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
堆栈跟踪:
[InvalidOperationException:SessionStateTempDataProvider要求启用SessionState.]
System.Web.Mvc.SessionStateTempDataProvider.LoadTempData(ControllerContext controllerContext)247928
System.Web.Mvc.TempDataDictionary.Load(ControllerContext controllerContext,ITempDataProvider tempDataProvider)30
System.Web.Mvc.Controller.ExecuteCore()71
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)209
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)171
解决方法
< modules runAllManagedModulesForAllRequests =“true”>
看起来我并不孤单:
http://forums.asp.net/p/1293974/2509190.aspx
http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/
我认为我的纯MVC项目(在Test环境中工作)过于简单,可能没有强制MVC框架要求TempData和SessionState,所以我将如何解释它;-)
How To Set a NLS Session Parameter At Database Or Schema Level For All Connections?
How To Set a NLS Session Parameter At Database Or Schema Level For All Connections? (Doc ID 251044.1) |
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=335038610424309&parent=DOCUMENT&sourceId=115001.1&id=251044.1&_afrWindowMode=0&_adf.ctrl-state=eqr5gy0az_53
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.0.3.0 to 11.2.0.3 [Release 8.0.3 to 11.2]
Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Information in this document applies to any platform.
PURPOSE
How to define some NLS session parameters for all clients, regardless of the used NLS_LANG (or other NLS parameter) setting on the client side
SCOPE
Anyone who want to control NLS settings from the server side.
DETAILS
Why to set a NLS session parameter at Database or Schema level for all connections?
The client side NLS setting will override the instance NLS settings like documented in Note 241047.1 The Priority of NLS Parameters Explained.
So you have no "server side" control on the used NLS session settings as they are derived from the client side.
However, if you like to overwrite some NLS session parameters for all clients, regardless of the used NLS_LANG (or other NLS parameter) setting on the client side then you can do that, for most environments, in the way described in this note.
Please note that:
* Oracle recommends you to define always the (correct) NLS_LANG.
The <characterset> part of the NLS_LANG is a (very important) client only parameter and cannot be set or defined from server side for a session.
Why this is so important is documented in Note 158577.1 and note 179133.1
* This is *not* working for some JDBC drivers , see Note 115001.1 NLS_LANG Client Settings and JDBC Drivers
And may also not work for other 3the party connection methods,if the connector issues from the driver itself alter sessions after the logon procedure of Oracle is done then they will override the trigger.
* When using a PL/SQL package procedure called by the logon trigger and this has any unhandled exceptions or raises any exceptions, then the logon trigger fails. When the logon trigger fails, the logon fails, that is, the user is denied permission to log in to the database
* We do NOT recommend to have several "after logon" triggers, for setting NLS parameters seen the execution order may differ. See Note 121196.1 Fire Sequence of Database Triggers
How to set a NLS session parameter at database level for all connections ?
Create an event trigger like this:
(Example for the NLS_TIMESTAMP_TZ_FORMAT parameter)
CREATE OR REPLACE TRIGGER sys.global_nls_session_settings AFTER LOGON ON DATABASE
BEGIN
execute immediate ''alter session set NLS_TIMESTAMP_TZ_FORMAT =''''DD/MM/YYYY HH24:MI:SS TZR TZD'''''';
END;
/
How to set a NLS session parameter at schema level for all connections ?
You can also create a logon trigger for one schema:
(Example for the NLS_DATE_FORMAT and NLS_NUMERIC_CHARACTERS parameter for the scott schema)
CREATE OR REPLACE TRIGGER sys.schema_nls_session_settings AFTER LOGON ON SCOTT.SCHEMA
BEGIN
execute immediate ''alter session set NLS_DATE_FORMAT=''''DD/MM/YYYY HH24:MI:SS'''''';
execute immediate ''alter session set NLS_NUMERIC_CHARACTERS=''''.,'''''';
END;
/
What NLS parameters can be set using logon triggers?
The parameters which can be set like this, are all the NLS parameters you can do an alter session for:
8i and up:
NLS_CALENDAR
NLS_COMP
NLS_CREDIT
NLS_CURRENCY
NLS_DATE_FORMAT
NLS_DATE_LANGUAGE
NLS_DEBIT
NLS_ISO_CURRENCY
NLS_LANGUAGE
NLS_LIST_SEPARATOR
NLS_MONETARY_CHARACTERS
NLS_NUMERIC_CHARACTERS
NLS_SORT
NLS_TERRITORY
NLS_DUAL_CURRENCY
NLS_TIMESTAMP_FORMAT
NLS_TIMESTAMP_TZ_FORMAT
new in 9i/10g:
NLS_LENGTH_SEMANTICS
NLS_NCHAR_CONV_EXCP
note: NLS_TIME_FORMAT and NLS_TIME_TZ_FORMAT are used internally only and should NOT be set or altered
Again, the client character set CANNOT be set or defined this way.
How to see if there are logon triggers?
This select gives you all defined after logon triggers:
conn / as sysdba
select OWNER, TRIGGER_NAME, TRIGGER_BODY from DBA_TRIGGERS where
trim(TRIGGERING_EVENT) = ''LOGON''
/
select OWNER, TRIGGER_NAME, TRIGGER_BODY from DBA_TRIGGERS where
upper(TRIGGER_NAME) = ''LOGON_PROC''
/
REFERENCES
NOTE:115001.1 - NLS_LANG Client Settings and JDBC Drivers
NOTE:241047.1 - The Priority of NLS Parameters Explained (Where To Define NLS Parameters)
Was this document helpful?
Document Details
Email link to this documentOpen document in new windowPrintable Page
Type:
Status:
Last Major Update:
Last Update:
BULLETIN
PUBLISHED
16-Jul-2015
06-Dec-2016
Related Products
Oracle Database - Enterprise Edition
Oracle Database - Enterprise Edition
Information Centers
Information Center: Overview Database Server/Client Installation and Upgrade/Migration [1351022.2]
Index of Oracle Database Information Centers [1568043.2]
インフォメーション・センター: データベースおよび Enterprise Manager 日本語ドキュメント [1946305.2]
Information Center: Overview of Database Security Products [1548952.2]
Document References
Recently Viewed
How To Set a NLS Session Parameter At Database Or Schema Level For All Connections? [251044.1]
NLS_LANG Client Settings and JDBC Drivers [115001.1]
IF: High Requests on dc_rollback_segments [1951703.1]
WebLogic Server:使用XA Datasource发生 - 获取“XAER_NOTA:XID无效”异常 [2357599.1]
How to Validate Network and Name Resolution Setup for the Clusterware and RAC [1054902.1]
Show More
Didn''t find what you are looking for?Ask in Community...
Related
Products
Oracle Database Products > Oracle Database Suite > Oracle Database > Oracle Database - Enterprise Edition > RDBMS
Oracle Database Products > Oracle Database Suite > Oracle Database > Oracle Database - Enterprise Edition > RDBMS > NLS Conversion issues, Characterset Conversion, Characterset issues (lossy and truncation data)
.net core cookie 登录和 session 的 DataProtectionProvider 加入 redis
string redisConnectionString = Configuration.GetSection("Storage:Redis").GetValue<string>("ConnectionString");
string redisInstanceName = Configuration.GetSection("Storage:Redis").GetValue<string>("InstanceName");
services.AddDistributedRedisCache(options =>
{
options.Configuration = $"{redisConnectionString},defaultDataBase=0";
options.InstanceName = redisInstanceName;
});
IDataProtectionBuilder dataProtectionBuilder = services.AddDataProtection()
.SetApplicationName("XXX")
.UseCryptographicAlgorithms(
new AuthenticatedEncryptorConfiguration()
{
EncryptionAlgorithm = EncryptionAlgorithm.AES_256_CBC,
ValidationAlgorithm = ValidationAlgorithm.HMACSHA256
})
.PersistKeysToRedis(ConnectionMultiplexer.Connect($"{redisConnectionString},defaultDataBase=0"), "XXX-DataProtection-Keys");
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(20); //session活期时间
options.Cookie = new CookieBuilder()
{
Name = $".{GetType().Namespace}.Session",
HttpOnly = true,
};
});
services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));//中文乱码
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.DataProtectionProvider = CreateRedisDataProtectionProvider(ConnectionMultiplexer.Connect($"{redisConnectionString},defaultDataBase=1"));
//options.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo(@"C:\_sso"));
options.SlidingExpiration = true;
options.LoginPath = "/account/signin";
options.Cookie = new CookieBuilder()
{
HttpOnly = true,
Name = $".{GetType().Namespace}",
};
});
IDataProtectionProvider CreateRedisDataProtectionProvider(IConnectionMultiplexer connection)
{
return new ServiceCollection()
.AddDataProtection()
.SetApplicationName("XXX.SSO")
.UseCryptographicAlgorithms(
new AuthenticatedEncryptorConfiguration()
{
EncryptionAlgorithm = EncryptionAlgorithm.AES_256_CBC,
ValidationAlgorithm = ValidationAlgorithm.HMACSHA256
})
.PersistKeysToRedis(connection, "XXX-SSO-DataProtection-Keys")
.Services
.BuildServiceProvider()
.GetRequiredService<IDataProtectionProvider>();
}
app.UseAuthentication();
app.UseSession();//在UseMvc前面
app.UseMvc();
.net – 如何处理System.Data.DataTableExtensions.CopyToDataTable()中的缺陷
导入(在VB.NET中)System.Data.DataTableExtensions然后针对IEnumerable调用该方法使用此方法.如果要使用LINQ过滤数据表,然后在最后还原DataTable,则可以执行此操作.
即:
Imports System.Data.DaTarowExtensions Imports System.Data.DataTableExtensions Public Class SomeClass Private Shared Function GetData() As DataTable Dim Data As DataTable Data = LegacyADO.NETDBCall Data = Data.AsEnumerable.Where(Function(dr) dr.Field(Of Integer)("SomeField") = 5).copyToDataTable() Return Data End Function End Class
在上面的示例中,“WHERE”过滤可能不会返回任何结果.如果发生这种情况,copyToDataTable会抛出异常,因为没有DaTarows.
为什么?
正确的行为应该是返回一个Rows.Count = 0的DataTable.
任何人都可以想到一个干净的解决方法,这样调用copyToDataTable的人不必知道这个问题吗?
System.Data.DataTableExtensions是一个静态类,所以我无法覆盖行为….任何想法?我错过了什么吗?
干杯
更新:
我已将此问题提交给Connect.我仍然想要一些建议,但如果您同意我的意见,可以通过以上链接在Connect上投票
干杯
someDataTable.AsEnumerable().Where(r => r.Field<string>("SomeField") == "SomeValue").AsDataView().ToTable();
.AsDataView().ToTable()返回一个空表,其结构与someDataTable相同,如果现在有从.Where()返回的行
ASP.NET sessionState SQLServer模式超时不起作用
我的web.config配置
<sessionState mode="sqlServer" allowCustomsqlDatabase="true" sqlConnectionString="Data Source=MYCON\sql2008REXPRESS;Initial Catalog=DBASPState; User ID=DB1543Write;Password=test" timeout="1" sqlCommandTimeout="10" regenerateExpiredSessionId="false" stateNetworkTimeout="10" compressionEnabled="true" cookieless="false" />
我在sessionstate数据库中检查了表ASPStateTempSessions并查看了其中的记录.读写,当前使用此数据库的urrent用户配置所有者权限. “Even Viewer”没有错误.
我已经检查了ASPStateTempSessions表中的值,并且在下面看起来似乎会话比较5小时比较1分钟.似乎asp.net使用另一个时区而不是当前的机器时区将其配置为在1分钟内过期.
我当前的时间是12/17/2011 11:29 AM
数据库列的值为CreatedDate(列)2011-12-17 17:29:01.677
到期(专栏)2011-12-17 17:30:03.903
有关数据库值的完整详细信息如下.
第一个记录是我第一次访问我的网站时
SessionId,Created,Expires,LockDate,LockDateLocal,LockCookie,Timeout,Locked,SessionItemShort,SessionItemLong,Flags 0wtp4j0traj5e0gydygkyoe22476b033 2011-12-17 17:29:01.677 2011-12-17 17:30:03.903 2011-12-17 17:29:03.873 2011-12-17 11:29:03.873 11 1 False <Binary data> NULL 0
在我按下浏览器上的“刷新”按钮后,记录已使用新的过期时间进行更新,但会话信息仍然存在
0wtp4j0traj5e0gydygkyoe22476b033 2011-12-17 17:29:01.677 2011-12-17 17:37:08.910 2011-12-17 17:36:08.907 2011-12-17 11:36:08.907 13 1 False <Binary data> NULL 0
有任何想法吗?
解决方法
当sql会话过期时,它们不会立即从会话表中删除,也不会收到Session_End事件.
sql会话提供程序不会主动监视会话表中的Expires列.相反,会话在从表中删除之前不会“正式”过期,这是通过调用DeleteExpiredSessions存储过程的sql代理作业完成的.默认情况下,作业配置为每60秒运行一次.当然,这意味着sql Agent需要运行才能使会话过期.这也意味着在“实际”到期之前,您需要在“名义”到期后至少等待60秒.
如果需要,您可以通过自己调用SP来强制过期.
今天关于asp.net-mvc – SessionStateTempDataProvider要求启用SessionState和启用session的语句是的讲解已经结束,谢谢您的阅读,如果想了解更多关于 How To Set a NLS Session Parameter At Database Or Schema Level For All Connections?、.net core cookie 登录和 session 的 DataProtectionProvider 加入 redis、.net – 如何处理System.Data.DataTableExtensions.CopyToDataTable()中的缺陷、ASP.NET sessionState SQLServer模式超时不起作用的相关知识,请在本站搜索。
本文标签: