HttpContext.Current.User is null after installing .NET Framework 4.5
private void Application_AuthenticateRequest(Object sender, EventArgs e)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
if (cookie != null)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(new FormsIdentity(ticket), new string[0]);
}
}
validation="SHA1" decryption="AES"
compatibilityMode="Framework20SP1" />
Since you're in 4.5 and since you're manually issuing the cookie and since you're already intercepting the cookie, then you're not really using the forms auth HTTP module at all. I'd remove that for now. Also, change your module to handle AuthenticateRequest. See how that works.
Then once you do get it working, I'd scrap it all in favor of claims and using the SessionAuthenticationModule which is new and built into 4.5. It is far simpler and will serialize all of your roles into a cookie for you.
http://msdn.microsoft.com/zh-cn/library/system.identitymodel.services.sessionauthenticationmodule(v=vs.110).aspx
5
Make sure that the machineKey compatibility mode is the same between all applications:
<machineKey compatibilityMode="Framework20SP1" />
(The above is the default for 2.0 / 4.0 applications but is not the default for 4.5 applications, so it will have to be set explictly in the 4.5 application.)
HttpContext.Current.User is null after installing .NET Framework 4.5的更多相关文章
- System.Web.HttpContext.Current.Session为NULL解决方法
http://www.cnblogs.com/tianguook/archive/2010/09/27/1836988.html 自定义 HTTP 处理程序,从IHttpHandler继承,在写Sys ...
- 为什么获取的System.Web.HttpContext.Current值为null,HttpContext对象为null时如何获取程序(站点)的根目录
ASP.NET提供了静态属性System.Web.HttpContext.Current,因此获取HttpContext对象就非常方便了.也正是因为这个原因,所以我们经常能见到直接访问System.W ...
- System.Web.HttpContext.Current.Session为NULL值的问题?
自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时 候,没有问题,但 ...
- 异步 HttpContext.Current 为空null 另一种解决方法
1.场景 在导入通讯录过程中,把导入的失败.成功的号码数进行统计,然后保存到session中,客户端通过轮询显示状态. 在实现过程中,使用的async调用方法,出现HttpContext.Curren ...
- 异步任务,HttpContext.Current为null解决办法
最近在开发一个后台管理系统项目,为了提高登录的速度,就把记录登录日志放到一个异步任务里面. Action taskAction = () => { SaveLog(); }; Task task ...
- HttpContext.Current 的缺陷
了解ASP.NET的开发人员都知道它有个非常强大的对象 HttpContext,而且为了方便,ASP.NET还为它提供了一个静态属性HttpContext.Current来访问它,今天的博客打算就从H ...
- HttpContext.Current.Server.MapPath("/") 未将对象设置到对象的实例异常。
多线程中的System.Web.HttpContext.Current.Server.MapPath("/") 多线程中Server.MapPath会失效... 网上找到几种解决方 ...
- HttpContext.Current并非无处不在
阅读目录 开始 无处不在的HttpContext HttpContext.Current到底保存在哪里? HttpContext并非无处不在! 如何获取文件绝对路径? 异步调用中如何访问HttpCon ...
- Cache及(HttpRuntime.Cache与HttpContext.Current.Cache)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/avon520/archive/2009/11/25/4872704.aspx .NET中Cache有两种调用方式:Ht ...
随机推荐
- C——malloc & free(转载自bccn C语言论坛)
原帖及讨论:http://bbs.bccn.net/thread-82212-1-1.html 原文链接:http://www.bccn.net/Article/kfyy/cyy/jszl/20060 ...
- Get Script Path in Shell
#!/usr/bin/bashdir_old=$(pwd)absolute_script_path=$(cd $(dirname $0) && pwd)relative_script_ ...
- pod
在运行 “sudo gem install cocoapods” 的时候出现问题:ERROR: While executing gem ... (Errno::EPERM)Operation not ...
- <java基础学习>JAVA 对象和类
Java is an Object-Oriented Language. As a language that has the Object Oriented feature, Java suppor ...
- Nginx中的进程亲和性 affinity
Nginx采用多进程Master/Worker结构,Worker进程数为CPU个数时工作效率最高,Nginx通过affinity为每个Worker进程绑定一个CPU,避免进程切换带来的消耗,同时能够保 ...
- gradle环境配置、
话不多说,直接上流程. 1.下载 gradle.zip文件,我以为已经为大家准备好了各个版本的下载地址. 链接: http://pan.baidu.com/s/1hqjIVlE 密码: 8ccb 本人 ...
- Longest Substring Without Repeating Characters (c#)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- Qt之C语言有符号数与无符号数运算
以32位的stm32f4为例: 1. uint32_t t_int_k = 239773, t_int_km1 = 4294859707; 则t_int_k - t_int_km1 > 0; ...
- SQL Server 内置函数、临时对象、流程控制
SQL Server 内置函数 日期时间函数 --返回当前系统日期时间 select getdate() as [datetime],sysdatetime() as [datetime2] getd ...
- C++ Windows进程管理
功能: 1.各个进程启动.挂起.恢复.停止等 2.监听进程的运行状态,进程退出(正常.非正常)时,通知用户 3.异步队列 4.线程安全 进程管理器类: #ifndef __ProcessManager ...