本文介绍了覆盖HttpContext.Current.User.Identity.Name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图钩到Web窗体ASP.NET管道,并以这样的方式延长 HttpContext.Current.User.Identity 名称属性返回一个定制的实现。

一个可行的办法,我已经找到in另一个答案的,它有可能通过添加的权利要求来添加新的属性。这两个问题我有是:


  1. 在何处添加在ASP.NET Web窗体管道索赔?和

  2. 是否有可能取代现有的名称属性?


解决方案

您可以在您的应用程序的Global.asax文件中PostAuthenticate事件。在FormsAuthenticationModule验证了窗体身份验证cookie后发生的事件PostAuthenticate

下面的链接可能会有所帮助:的

I am trying to hook into the Web Forms ASP.NET pipeline and extend the HttpContext.Current.User.Identity in such a way that the Name property returns a custom implementation.

One possible approach which I have found in another answer that it is possible to add new properties by adding claims. The two questions I have are:

  1. Where to add the claims in the ASP.NET Web Forms pipeline? And
  2. Is it possible to override the existing Name property?
解决方案

You can implement the PostAuthenticate event in your application's Global.asax file. The PostAuthenticate event occurs after the FormsAuthenticationModule has verified the forms authentication cookie.

the following link might be helpful: http://bytes.com/topic/asp-net/answers/860607-setting-httpcontext-current-user

这篇关于覆盖HttpContext.Current.User.Identity.Name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 22:20