【发布时间】:2020-03-21 07:57:03
【问题描述】:
我试图在现有应用程序中实现 OWIN WS Federation。它是asp .net VB 中的Web 应用程序。 我已经添加了 Nugetpackages 中的所有引用 List of refernces added
然后我在 2 个文件中添加了启动类作为 Partial 类。
StartupAuth.vb:
Imports System.Configuration
Imports System.Globalization
Imports System.Threading.Tasks
Imports Microsoft.Owin.Extensions
Imports Microsoft.Owin.Security
Imports Microsoft.Owin.Security.Cookies
Imports Microsoft.Owin.Security.WsFederation
Imports Owin
Partial Public Class Startup
Private Shared realm As String = ConfigurationManager.AppSettings("ida:Wtrealm")
Private Shared adfsMetadata As String = ConfigurationManager.AppSettings("ida:ADFSMetadata")
Public Sub ConfigureAuth(app As IAppBuilder)
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType)
app.UseCookieAuthentication(New CookieAuthenticationOptions())
app.UseWsFederationAuthentication(New WsFederationAuthenticationOptions() With {
.Wtrealm = realm,
.MetadataAddress = adfsMetadata
})
' This makes any middleware defined above this line run before the Authorization rule is applied in web.config
app.UseStageMarker(PipelineStage.Authenticate)
End Sub
End Class
和 Startup.vb:
Imports Microsoft.Owin
Imports Owin
<Assembly: OwinStartupAttribute(GetType(Startup))>
Partial Public Class Startup
Public Sub Configuration(app As IAppBuilder)
ConfigureAuth(app)
End Sub
End Class
我还在 webconfig 中添加了这两行:
<add key="owin:HandleAllRequests" value="true" />
<add key="owin:AppStartup" value="Startup.vb" />
如果有人知道发生了什么,请告诉我。
提前致谢。
因为我没有项目和启动文件的命名空间,所以我没有在配置文件中添加它。当我尝试运行应用程序时,出现以下错误:
【问题讨论】:
标签: asp.net vb.net owin startup app-startup