Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET MVC3-ActionResult呈现DotNetOpenAuth WebResponse作为字符串_Asp.net_Dotnetopenauth_Asp.net Mvc 3 - Fatal编程技术网

ASP.NET MVC3-ActionResult呈现DotNetOpenAuth WebResponse作为字符串

ASP.NET MVC3-ActionResult呈现DotNetOpenAuth WebResponse作为字符串,asp.net,dotnetopenauth,asp.net-mvc-3,Asp.net,Dotnetopenauth,Asp.net Mvc 3,我刚刚更新了我的MVC2项目以运行MVC3(RC)。除了一个问题外,一切都正常工作 我正在运行DotNetOpenAuth,但当我进行身份验证时,我的页面会呈现字符串 DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult 而不是验证(在MVC2应用程序中工作) 我发现了这个问题,我按照建议做了,但没有用 这是我的Web.Config的一个剪辑 </configSections> <runtime> <

我刚刚更新了我的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>

还有什么可能导致此问题

如果有帮助,下面是MVC3之前的控制器代码

    ''# <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
“”#####此代码被注释掉,以便在StackOverflow上正确显示-在项目中它实际上没有被注释掉。
公共函数身份验证(ByVal go As String)作为ActionResult
Dim响应为IAAuthenticationResponse=openid.GetResponse()
如果回答什么都不是,那么
''#第2阶段:用户提交标识符
作为标识符的Dim id
如果Identifier.TryParse(Request.Form(“openid_Identifier”),id),那么
尝试
返回openid.CreateRequest(Request.Form(“openid_标识符”)).RedirectingResponse.AsActionResult()
作为协议例外的捕获物
ViewData(“消息”)=“Woops!”&例如消息
返回视图(“登录”)
结束尝试
其他的
ViewData(“消息”)=“Woops!无效标识符”
返回视图(“登录”)
如果结束
其他的
''#第3阶段:OpenID提供程序发送断言响应
选择案例响应。状态
案例身份验证状态。已验证
如果没有OpenIDService.isopenidaAssociated(response.ClaimedIdentifier),那么
''如果用户登录,所有这些都会发生
''#目前没有与关联的帐户
“他们的OpenId。我们可能想处理这个问题
“#通过将他们发送到
''允许他们确认帐户创建或尝试
“又来了。
''#TODO:创建Authenticate视图和CreateUser ActionResult(无视图)
UserService.AddUser(response.ClaimedIdentifier,response.FriendlyIdentifierForDisplay)
UserService.SubmitChanges()
ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID_
ActivityLog.LogType.UserAdded_
HttpContext.Request.UserHostAddress)
其他的
ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID_
ActivityLog.LogType.UserLogin_
HttpContext.Request.UserHostAddress)
如果结束
''#同样,我们希望确保将用户关联起来
''#在ActivityLog中添加一个条目的操作,以便进一步了解
''与徽章一起使用
ActivityLogService.SubmitChanges()
''#创建身份验证cookie。这个饼干
''将AuthUserData信息包含在
''#FormsAuthenticationCookie的userData字段。
Dim authUser As AUTHICATION.AuthUserData=新身份验证.AuthUserData(OpenIDService.GetOpenId(response.ClaimedIdentifier.User)
HttpContext.Response.Cookies.Add(Authentication.CustomAuthentication.CreateAuthCookie(Response.ClaimedIdentifier_
authUser_
正确的)
authUser=无
如果不是String.IsNullOrEmpty(go),则:返回重定向(go)
其他:返回重定向到操作(“索引”、“事件”)
如果结束
案例身份验证状态。已取消
ViewData(“消息”)=“在提供程序处取消”
返回视图(“登录”)
案例身份验证状态。失败
ViewData(“消息”)=response.Exception.Message
返回视图(“登录”)
结束选择
如果结束
返回新的EmptyResult()
端函数

这似乎解决了问题。。。我应该使用不同版本的DotNetOpenAuth吗?我的当前版本是[版本-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>

仅根据chase的答案,您可以将oldVersion设置为一个范围,从而节省您多次编写的时间

</configSections>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
<system.web.webPages.razor>


您可能希望升级到最新的DotNetOpenAuth,因为当前的版本是v3.4.5,但它无法“解决”此问题。DotNetOpenAuth针对MVC1.0进行编译,因此它适用于较旧的安装。绑定重定向是正确的修复方法。谢谢!这件事困扰了我很长一段时间。将此添加到我的web.config中就成功了。