zoukankan      html  css  js  c++  java
  • 竟然遇到取FormAuthentication的值取不出来的情况

    在开发中,竟然遇到取FormAuthentication的值取不出来的情况,忘了以前是怎么理解这个问题的了,为了避免问题,先放上来,容后再描述。

     出现问题的原因是当在自定义的HttpModule类中取用户的信息时,竟然什么都取不出来,以前好像解决过这个问题,但是这次竟然花了3个小时才搞懂,看来确实是老了!!

     解决方法是由于FormAuthentication实际上是由FormsAuthenticationModule实现的,所以在Web.config中重新声明这些个Module,问题就解决了.(并且一定要在你想用的Module的前面)

     <remove name="FormsAuthenticationModule" />
       <add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />
       <remove name="UrlAuthorization" />
       <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
       <remove name="DefaultAuthentication" />
       <add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" />

    具体的原理也没搞懂,厄~~

  • 相关阅读:
    PAT 1142 Maximal Clique
    PAT 1076 Forwards on Weibo
    PAT 1021 Deepest Root
    PAT 1030 Travel Plan*
    diji模板
    PAT 1020 Tree Traversals
    PAT 1108 Finding Average
    PAT 1104 Sum of Number Segments
    PAT 1100 Mars Numbers
    PAT 1096 Consecutive Factors
  • 原文地址:https://www.cnblogs.com/csharpsharper/p/1336056.html
Copyright © 2011-2022 走看看