I was trying to implement OWIN WS Federation in an existing application. It's a web application in asp .net VB. I have added all the references from the Nugetpackages List of refernces added
Then I added the startup class in 2 files as a Partial
class.
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
and 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
I also added these two lines in the webconfig:
<add key="owin:HandleAllRequests" value="true" />
<add key="owin:AppStartup" value="Startup.vb" />
If anyone has any idea about what is happening please let me know.
thanks in advance.
As I dont have a namespace for the project and the startup files I have not added it in the config file. When I try to run the application I get the following error: