I've just updated my MVC2 project to run MVC3 (RC). Everything is working as expected except for one problem.
I'm running DotNetOpenAuth, but when I go to authenticate, my page renders the string
DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult
instead of authenticating (which worked in the MVC2 app)
I found this question elsewhere on SO, and I did what was suggested, but to no avail.
Here is a clip of my Web.Config
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc"
pub开发者_开发百科licKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.web.webPages.razor>
What else could be causing this problem?
If it helps, here's the Controller code that was working prior to 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
Well this seems to have solved the problem... Should I be using a different version of DotNetOpenAuth? My current version is [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>
Just to build on chase's answer you can set oldVersion as a range, saving you writing it multiple times
</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>
精彩评论