【问题标题】:dotnetopenauth asp.net mvc2 project template - broken when running from localhost:xxxxdotnetopenauth asp.net mvc2 项目模板 - 从 localhost:xxxx 运行时损坏
【发布时间】:2010-07-24 18:13:47
【问题描述】:

所以我从模板创建了一个新的 dnoa mvc2 站点,运行 setup.aspx 没有问题,登录并授权我的 openid - 一切正常,但重定向到

http://localhost:18916/Auth/PopUpReturnTo?dnoa.uipopup=1&dnoa.popupUISupported=1&index=0&dnoa.userSuppliedIdentifier=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid&dnoa.op_endpoint=https%3A% 2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&dnoa.claimed_id=&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F% 2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2010-07-24T18%3A06%3A36ZcustWWIY5CfXTQ&openid.return_to=http%3A%2F%2Flocalhost%3A18916%2FAuth%2FpopUpReturnTo%3Fdnoa.uipopup%3D1%26dnoa.Supported 3D1%26index%3D0%26dnoa.userSuppliedIdentifier%3Dhttps%253A%252F%252Fwww.google.com%252Faccounts%252Fo8%252Fid%26dnoa.op_endpoint%3Dhttps%253A%252F%252Fwww.google.com%252Faccounts%252Fo8%252Fud% 26dnoa.claimed_id%3D&openid.assoc_handle=AOQobUdkpLPAPC1LRQKPaQcy2UlG8R4pjWmpDCSV_1odtA33o_HfNleiMi9ZjX8RU-kIIJnJ&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle% e.alias3%2Cext1.value.alias3%2Cext1.type.alias1%2Cext1.value.alias1&openid.sig=zkBfpugK7xT0da49hZLNQZz4Xn83UiZB%2BhEHz6B37Cw%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid% 3Fid%3DAItOawk3FGqct35R7wya-0Bkq-0_Qnc1AB-YSw4&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk3FGqct35R7wya-0Bkq-0_Qnc1AB-YSw4&openid.ns.ext1=http%A 2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.alias3=http%3A%2F%2Fschema.openid.net%2Fcontact%2Femail&openid.ext1.value.alias3=sky.sanders% 40gmail.com&openid.ext1.type.alias1=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.alias1=sky.sanders%40gmail.com&openid.ns.ext2=http%3A%2F%2Fspecs。 openid.net%2Fextensions%2Fui%2F1.0&openid.ext2.mode=popup

我得到的只是一个警报[object Error]

“开始”说我要做的就是设置数据库,然后就可以开始了。

这似乎不太好。如果有其他标准可以使示例正常工作,则应声明它们。

无论如何,要在 localhost:xxx (cassini/cassinidev) 上运行它需要什么?

【问题讨论】:

    标签: visual-studio-2010 asp.net-mvc-2 dotnetopenauth


    【解决方案1】:

    您看到的是由于 IE8 中的一个错误与跨信任区域(从本地计算机/Intranet 到 Internet 区域)有关。如果您使用非 IE 浏览器,它将工作。当您在 Internet 上发布您的网站时,IE8 可以正常工作,因为它在登录期间不会进入 Intranet 区域。

    【讨论】:

    • 谢谢。问题是在非ie浏览器中,visual studio javascript调试不可用。 IE7兼容模式呢? (我知道我可以检查但想在这里得到一个答案,以启发可能遇到此问题的 x,xxx 人数)
    • 在我的实现中似乎根本没有遇到与 IE8 相同的问题。一切都按预期工作。
    • 该代码实际上是直接从其中一个示例中提取的。
    • @rock - 很酷。安德鲁,当场。而且,不,IE7 兼容模式也好不到哪里去。尽管您可能希望在 IE7 中查看您的弹出窗口,但提供程序 div 会堆叠在一起,从而导致滚动弹出窗口。
    • 是的,我还没有确定 HTML 以使其始终适用于所有浏览器。 @rock,您的示例代码中的代码工作正常。是客户端上的 javascript 使弹出窗口出现故障。如果您不使用 iframe 或弹出窗口,则不会出现此问题。
    【解决方案2】:

    我正在使用您之前给我的方法进行身份验证,这是我的控制器身份验证代码

        <ValidateInput(False)> _
        Public Function Authenticate(ByVal returnUrl As String) As ActionResult
            Dim response = 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") = ex.Message
                        Return View("Login")
                    End Try
    
                Else
    
                    ViewData("Message") = "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
                            UserService.AddUser(response.ClaimedIdentifier, response.FriendlyIdentifierForDisplay)
                            UserService.SubmitChanges()
    
                            ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                               Utilities.ActivityLog.LogType.UserAdded, _
                                                               HttpContext.Request.UserHostAddress)
    
                        Else
                            ActivityLogService.AddActivity(OpenIDService.GetOpenId(response.ClaimedIdentifier).UserID, _
                                                               Utilities.ActivityLog.LogType.UserLogin, _
                                                               HttpContext.Request.UserHostAddress)
                        End If
                        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(returnUrl) Then : Return Redirect(returnUrl)
                        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
    

    我的数据库中有一个名为Users 的自定义表,我还有一个带有UserID 字段的OpenIDs 表。 OpenIds 表允许我为每个用户拥有无限数量的 OpenId。

    所有这些都适用于我在本地以及生产服务器和登台服务器上。

    【讨论】:

    • PS:我没有使用下载附带的任何“启动”代码...我只是手动实现了所有内容...实际上很轻松。
    猜你喜欢
    • 2020-02-22
    • 2016-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-29
    • 2011-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多