ASP.NET MVC3 - ActionResult将DotNetOpenAuth WebResponse呈现为String

Cha*_*ell 4 asp.net dotnetopenauth asp.net-mvc-3

我刚刚更新了我的MVC2项目来运行MVC3(RC).除了一个问题,一切都按预期工作.

我正在运行DotNetOpenAuth,但是当我进行身份验证时,我的页面会呈现字符串

DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult

而不是验证(在MVC2应用程序中工作)

我在其他地方发现了这个问题,我做了所建议的,但无济于事.

这是我的Web.Config的剪辑

</configSections>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc"
                publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<system.web.webPages.razor>
Run Code Online (Sandbox Code Playgroud)

还有什么可能导致这个问题?

如果它有帮助,这是在MVC3之前工作的Controller代码

    ''# <ValidateInput(False)> _  ''# this code is commented out so that it displays properly on StackOverflow - It's not really commented out in the project.
    Public Function Authenticate(ByVal go As String) As ActionResult
        Dim response As IAuthenticationResponse = openid.GetResponse()
        If response Is Nothing Then
            ''# Stage 2: user submitting Identifier
            Dim id As Identifier

            If Identifier.TryParse(Request.Form("openid_identifier"), id) Then

                Try
                    Return openid.CreateRequest(Request.Form("openid_identifier")).RedirectingResponse.AsActionResult()
                Catch ex As ProtocolException
                    ViewData("Message") = "Woops! " & ex.Message
                    Return View("Login")
                End Try

            Else

                ViewData("Message") = "Woops! Invalid identifier"
                Return View("Login")
            End If
        Else
            ''# Stage 3: OpenID Provider sending assertion response
            Select Case response.Status
                Case AuthenticationStatus.Authenticated

                    If Not OpenIDService.IsOpenIdAssociated(response.ClaimedIdentifier) Then
                        ''# All of this happens if the user logging in does
                        ''# not currently have an account associated with
                        ''# their OpenId.  We probably want to handle this a
                        ''# little differently by sending them to a view that
                        ''# allows them to confirm account creation or try
                        ''# again. 
                        ''# TODO: Create an Authenticate View and a CreateUser ActionResult (without a View)
                        UserService.AddUser(response.ClaimedIdentifier, response.FriendlyIdentifierForDisplay)
                        UserService.SubmitChanges()

                        ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                           ActivityLog.LogType.UserAdded, _
                                                           HttpContext.Request.UserHostAddress)

                    Else
                        ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                           ActivityLog.LogType.UserLogin, _
                                                           HttpContext.Request.UserHostAddress)
                    End If

                    ''# Again, we want to make sure to associate the users
                    ''# actions with an entry in the ActivityLog for further
                    ''# use with Badges
                    ActivityLogService.SubmitChanges()


                    ''# Create the authentication cookie.  This cookie
                    ''# includes the AuthUserData information in the
                    ''# userData field of the FormsAuthentication Cookie.
                    Dim authUser As Authentication.AuthUserData = New Authentication.AuthUserData(OpenIDService.GetOpenId(response.ClaimedIdentifier).User)
                    HttpContext.Response.Cookies.Add(Authentication.CustomAuthentication.CreateAuthCookie(response.ClaimedIdentifier, _
                                                                                                          authUser, _
                                                                                                          True))
                    authUser = Nothing

                    If Not String.IsNullOrEmpty(go) Then : Return Redirect(go)
                    Else : Return RedirectToAction("Index", "Events")
                    End If

                Case AuthenticationStatus.Canceled
                    ViewData("Message") = "Canceled at provider"
                    Return View("Login")

                Case AuthenticationStatus.Failed
                    ViewData("Message") = response.Exception.Message
                    Return View("Login")

            End Select
        End If
        Return New EmptyResult()
    End Function
Run Code Online (Sandbox Code Playgroud)

Cha*_*ell 5

好吧,这似乎已经解决了问题......我应该使用不同版本的DotNetOpenAuth吗?我目前的版本是[Version - 3.4.3.10143]

</configSections>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc"
                publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.0.0" newVersion="3.0.0.0"/>
            <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<system.web.webPages.razor>
Run Code Online (Sandbox Code Playgroud)