I have two VS 2013 MVC 5 SPA web projects. Both are newly created and have not been modified (i.e. still the vanilla template). One of them works and one does not. The only difference that I can see is that one was created in a project that has been upgraded from VS 2010 to VS 2012 and then to 2013 and is one of about 60-70 projects in the solution. The other is a newly created solution with the MVC app as the only project in it.
The fresh MVC app in it's own solution works without any problem, however, the MVC app that was added to the upgraded project gives the following compile time error:
'UseExternalSignInCookie' is not a member of 'Owin.IAppBuilder'. ...\Mvc5UI\App_Start\Startup.Auth.vb
'UseOAuthBearerTokens' is not a member of 'Owin.IAppBuilder'. ...\Mvc5UI\App_Start\Startup.Auth.vb
'GetExternalAuthenticationTypes' is not a member of 'Microsoft.Owin.Security.IAuthenticationManager'. ...\Mvc5UI\Controllers\AccountController.vb
The code where the problem is (Startup.Auth.vb):
Public Sub ConfigureAuth(app As IAppBuilder)
'...
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie)
app.UseOAuthBearerTokens(OAuthOptions)
'...
End Sub
and (AccountController.vb)
Public Function GetExternalLogins(returnUrl As String, Optional generateState As Boolean = False) As IEnumerable(Of ExternalLoginViewModel)
Dim descriptions As IEnumerable(Of AuthenticationDescription) = Authentication.GetExternalAuthenticationTypes()
'...
End Sub
This code is the same in both the upgraded solution and the newly built solution, so there's something environmental going on. I've made sure that the NuGet packages are setup correctly. The thing that I find most interesting (and is probably a misunderstanding on my part) is that when I explore the assembly metadata for IAppBuilder
I don't see any of the methods that are referenced, so the error makes sense. However, then the question becomes, why does it work in the newly created MVC app?
As I was writing the question, I was able to determine the answer. The UseExternalSignInCookie
and UseOAuthBearerTokens
methods are actually extension methods on the IAppBuilder, which is why I was confused. These extension methods are found in Microsoft.Owin.Security.Cookies which was apparently not being referenced correctly.
After figuring that out and as I was going through the project references, I noticed that the Microsoft.AspNet.Identity.Owin assembly reference was broken, so I reinstalled that package with update-Package -reinstall Microsoft.AspNet.Identity.Owin
package manager command and then everything started working.
I'm still not sure why this was broken to begin with, but it's working now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With