2017-12-28 8 views
-1

OWINライブラリを使用してシングルサインオンを使用しようとしています。私が動作しているコードは、MVC C#です。 VBでForm Webサイトに翻訳しようとしています。ここではC#のコードは、それが動作しますが、次のとおりです。OWINシングルサインオンのために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のコードは次のとおりです。

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 
関連する問題