2017-01-09 52 views
0

配置ASP.NET身份驗證時,如果將身份驗證模式設置爲Windows,但子元素forms元素應該是什麼樣的行爲?例如,下面的配置是作爲默認in MSDNWindows身份驗證模式的行爲,具有表單子元素?

<authentication mode="Windows"> 
    <forms 
     name=".ASPXAUTH" 
     loginUrl="login.aspx" 
     defaultUrl="default.aspx" 
     protection="All" 
     timeout="30" 
     path="/" 
     requireSSL="false" 
     slidingExpiration="true" 
     cookieless="UseDeviceProfile" domain="" 
     enableCrossAppRedirects="false"> 
     <credentials passwordFormat="SHA1" /> 
    </forms> 
    <passport redirectUrl="internal" /> 
</authentication> 

不過,我看到的是什麼意思零文檔在這裏發生。子元素forms的所有文檔都假定驗證模式爲Forms。特別奇怪的是,這沒有記錄,因爲這是默認設置。那麼爲什麼Windows認證模式有一個forms子元素?子元素是否會被忽略,如果你想將模式切換到Forms,或者它是否做了更多的事情,它只是作爲你可能想要的一個例子嗎?

回答

1

我認爲這只是爲了舉例。我看不出任何文檔,但看着代碼,它看起來像的形式設置是隻讀驗證模式是形式

下面是FormsAuthenticationModule.cs

​​

請注意:FormsAuthentication.Initialize被稱爲只有當模式形式,它讀取形式從網絡設置。配置文件。

的代碼是從FormsAuthenciation.cs文件

/// /// Initializes FormsAuthentication by reading /// configuration and getting the cookie values and encryption keys for the given /// application. /// public static void Initialize() { if (_Initialized) return; lock(_lockObject) { if (_Initialized) return; AuthenticationSection settings = RuntimeConfig.GetAppConfig().Authentication; settings.ValidateAuthenticationMode(); _FormsName = settings.Forms.Name; _RequireSSL = settings.Forms.RequireSSL; _SlidingExpiration = settings.Forms.SlidingExpiration; if (_FormsName == null) _FormsName = CONFIG_DEFAULT_COOKIE; _Protection = settings.Forms.Protection; _Timeout = (int) settings.Forms.Timeout.TotalMinutes; _FormsCookiePath = settings.Forms.Path; _LoginUrl = settings.Forms.LoginUrl; if (_LoginUrl == null) _LoginUrl = "login.aspx"; _DefaultUrl = settings.Forms.DefaultUrl; if (_DefaultUrl == null) _DefaultUrl = "default.aspx"; _CookieMode = settings.Forms.Cookieless; _CookieDomain = settings.Forms.Domain; _EnableCrossAppRedirects = settings.Forms.EnableCrossAppRedirects; _TicketCompatibilityMode = settings.Forms.TicketCompatibilityMode; _Initialized = true; } }

相關問題