2017-12-28 11 views
-1

OWIN 라이브러리를 사용하여 Single Sign On을 사용하려고합니다. 그 코드가 MVC C#에 있습니다. VB에서 양식 웹 사이트로 변환하려고합니다. 여기OWIN Single Sign On에 대해 C#을 VB로 변환

public void ConfigureAuth(IAppBuilder app) 
{ 
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); 
    app.UseCookieAuthentication(new CookieAuthenticationOptions()); 
    app.UseWsFederationAuthentication(
     new WsFederationAuthenticationOptions 
     { 
      Wtrealm = realm, 
      MetadataAddress = metadata, 
      Notifications = new WsFederationAuthenticationNotifications 
      { 
       AuthenticationFailed = context => 
       { 
        context.HandleResponse(); 
        context.Response.Redirect("Home/Error?message=" + context.Exception.Message); 
        return Task.FromResult(0); 
       } 
      } 
     }); 
} 

을 그리고 VB.Net 코드 : 여기에 작동하는 C# 코드이며,

Public Sub ConfigureAuth(app As IAppBuilder) 
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType) 
    app.UseCookieAuthentication(New CookieAuthenticationOptions()) 
    Dim authOption As WsFederationAuthenticationOptions = New WsFederationAuthenticationOptions() 

    app.UseWsFederationAuthentication(New WsFederationAuthenticationOptions() With { 
     .Wtrealm = realm, 
     .MetadataAddress = metadata 
    }) 

End Sub 

나는 내가 왼쪽으로로 제대로 번역 UseWsFederationAuthentication 코드를 가지고 있다고 생각하지 않습니다 알림 내용은 번역하는 방법을 알 수 없었기 때문에 오류는 발생하지 않지만 제대로 인증되지 않습니다. 번역에 문제가 있는지, 해결 방법은 누구에게 말해 줄 수 있습니까?

답변

0

정말 테스트 할 수 없습니다. 그러나 이것을 시도하십시오 :

Public Sub ConfigureAuth(app As IAppBuilder) 
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType) 
    app.UseCookieAuthentication(New CookieAuthenticationOptions()) 

    app.UseWsFederationAuthentication(New WsFederationAuthenticationOptions() With { 
    .Wtrealm = realm, 
    .MetadataAddress = metadata, 
    .Notifications = New WsFederationAuthenticationNotifications() With { 
          .AuthenticationFailed = Function(context) 
           context.HandleResponse() 
           context.Response.Redirect("Home/Error?message=" + context.Exception.Message) 
           Return Task.FromResult(0) 
          End Function 
    } 
    }) 
End Sub