現在我試圖找出如何asp.net mvc身份驗證的細節。據我所知,完全FormsAuthenticationModule檢查cookie並填充HttpContext.User。但我無法找到FormsAuthenticationModule爲我的應用程序註冊的位置?FormsAuthenticationModule在哪裏註冊?
回答
但我無法找到FormsAuthenticationModule在哪裏註冊了我的應用程序?
當您在web.config中設置<authentication mode="Forms">
時,它將自動由ASP.NET運行時註冊。
如果你感興趣的細節,你可以看看ASP.NET的源代碼和更具體的HttpApplication
類,如果你註冊該調用FormsAuthentication模塊的Init
方法InitModulesCommon
私有方法在你的web.config。
FormsAuthentication模塊本身一旦註冊,將訂閱HTTP處理管道的AuthenticateRequest
事件,它將嘗試根據請求中發送的表單身份驗證cookie中存在的值,將IPrincipal構建到當前HttpContext中。
在應用程序成員資格提供程序中使用formsauthenticationmodule註冊以獲取有關用戶的數據嗎? – mtkachenko
不,表單身份驗證與成員資格提供程序完全無關。那些是可以獨立使用的兩種完全不同的東西。 –
模塊如何獲取用戶名? – mtkachenko
它從根web.config繼承。例如,如果您在x64機器上安裝了.NET 4,請打開C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
。在system.web
部分,你會發現註冊以下模塊:
<httpModules>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
**<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />**
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule" />
<add name="RoleManager" type="System.Web.Security.RoleManagerModule" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" />
<add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" />
<add name="Profile" type="System.Web.Profile.ProfileModule" />
<add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />
<add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
ASP.NET與所有web.config
文件合併它發現沿層次文件系統上,因此應用程序默認啓用的所有模塊。
- 1. MvcRouteHandler在哪裏註冊
- 2. 在哪裏註冊kobold2d NSUserDefaults
- 3. 動作監聽器在哪裏註冊?
- 4. 用戶註冊信息在哪裏?
- 5. 在哪裏註冊C#事件?
- 6. 在哪裏註冊applicationWillResignActive使用UIStoryboard
- 7. 註冊服務器在哪裏存儲?
- 8. 我在哪裏取消註冊NSNotification?
- 9. Restlet + Jackson - 在哪裏註冊模塊
- 10. 哪裏存儲MVC 4註冊用戶?
- 11. 註冊/安裝組件去了哪裏?
- 12. 從哪裏獲得GCM註冊ID?
- 13. 注入路由註冊時,在哪裏調用RouteDebugger.RewriteRoutesForTesting()?
- 14. 我在哪裏可以在ASP.NET應用程序中註冊IMemoryCache?
- 15. R0和R1在內存映射中註冊在哪裏?
- 16. 在cdev_add()成功註冊117後,char設備出現在哪裏。
- 17. IApplicationServices在ABP框架中註冊在哪裏?
- 18. 在Symfony中,我在哪裏註冊自定義DQL函數?
- 19. 用戶註冊數據與node.js存儲在哪裏
- 20. UninstallString註冊表項的所有可能位置在哪裏?
- 21. Windows XP:在哪裏寫入註冊表從IE?
- 22. spi-omap2-mcspi.c中註冊的McSPIx的基地址在哪裏?
- 23. Android:應該在哪裏定義/註冊OnSharedPreferenceChangeListener
- 24. 我應該在哪裏取消註冊UWP Application.Current.Suspending事件?
- 25. 註冊接收Android的GCM,在哪裏和多少次?
- 26. 什麼/在哪裏修改Django的註冊與移動broswers
- 27. 哪裏在Windows 10註冊表是用戶的主題顏色
- 28. 我在哪裏可以找到Apple Developer程序的註冊ID?
- 29. 哪裏可以在Windows開發人員中心註冊WNS
- 30. 在哪裏最好註冊Angular 2提供者
它已在Web服務器級別上註冊。假設你在IIS上運行,轉到IIS管理器,選擇頂層並單擊模塊,然後你會發現它 – Uriil
並且依賴於認證類型(窗口或窗體)iis調用適當的認證模塊(WindowsAuthenticationModule或FormsAuthenticationModule)? – mtkachenko