asp.net – 使用OpenOAuthProvider通过Google进行身份验证
发布时间:2020-12-16 03:24:04 所属栏目:asp.Net 来源:网络整理
导读:我在Visual Studio中创建了默认的ASP.NET项目模板,然后转到App_Start文件夹中的AuthConfig.然后我取消注释以下行: OpenAuth.AuthenticationClients.AddGoogle(); 我得到了像Google一样登录Google的按钮: 当我点击Google按钮时,我收到此错误: An exception
我在Visual Studio中创建了默认的ASP.NET项目模板,然后转到App_Start文件夹中的AuthConfig.然后我取消注释以下行:
OpenAuth.AuthenticationClients.AddGoogle(); 我得到了像Google一样登录Google的按钮: 当我点击Google按钮时,我收到此错误: An exception of type 'DotNetOpenAuth.Messaging.ProtocolException' occurred in DotNetOpenAuth.OpenId.RelyingParty.dll but was not handled in user code Additional information: No OpenID endpoint found. WE.config文件 <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application,please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <configSections> <!-- For more information on Entity Framework configuration,visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version=5.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> <pages> <namespaces> <add namespace="System.Web.Optimization" /> </namespaces> <controls> <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /> </controls></pages> <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" /> </authentication> <profile defaultProvider="DefaultProfileProvider"> <providers> <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider,System.Web.Providers,Version=1.0.0.0,PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" /> </providers> </profile> <membership defaultProvider="DefaultMembershipProvider"> <providers> <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider,PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <roleManager defaultProvider="DefaultRoleProvider"> <providers> <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider,PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" /> </providers> </roleManager> <sessionState mode="InProc" customProvider="DefaultSessionProvider"> <providers> <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider,PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /> </providers> </sessionState> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" /> <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" /> </entityFramework> <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings> </configuration> 请帮我.我错过了什么? 解决方法
实际上这种实现(OpenId)是
deprecated.如果可能,你应该改为MVC5.在MVC5中,它是非常
straightforward.该解决方案仍然有效.如果您不能,则需要编写此
yourself或使用使用OAuth2与Google通信的第三方组件.有关不推荐使用的功能的更多信息,请参见
this answer.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc-4 – 使用导航路由的ASP.NET,Twitter.Bootstra
- asp.net-core – CoreCLR中的MD5CryptoServiceProvider的替
- asp.net-mvc – 自动发布使用TFS和MSBuild构建,无需调试文件
- 在ASP.NET中生成新的SessionId
- asp.net-mvc – MVC反伪造令牌如何在Web服务器重启之间存活
- 什么是ASP.NET-MVC 5.1中的ManageController.cs及其创建原因
- asp.net-mvc – ASP.NET MVC 3不显眼的客户端验证
- asp.net – 未在生产服务器中的WCF调用上传递凭据
- asp.net-mvc – 客户端存储的身份验证令牌在哪里?
- asp.net-mvc-3 – ASP.NET MVC – 扩展Ajax.ActionLink方法