asp.net-mvc-3 – 使用Razor视图抛出有关DotNetOpenAuth.IEmbedd
发布时间:2020-12-16 00:15:42 所属栏目:asp.Net 来源:网络整理
导读:当我的Razor视图调用@ Html.OpenIdSelector时(…我得到一个InvalidOperationException: The current IHttpHandler is not one of types: System.Web.UI.Page, DotNetOpenAuth.IEmbeddedResourceRetrieval. An embedded resource URL provider must be set i
|
当我的Razor视图调用@ Html.OpenIdSelector时(…我得到一个InvalidOperationException:
我应该在配置文件中设置什么? 解决方法
只需
NuGet DotNetOpenAuth包.它将在配置文件中设置您需要的所有内容:
>在解决方案资源管理器中右键单击Web项目的引用 一切都将自动设置,正确的组件将从互联网上下载并作为参考添加. 以下是执行此操作后web.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=152368
-->
<configuration>
<configSections>
<section name="uri" type="System.Configuration.UriSection,System,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
<section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true" />
</configSections>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions,Version=4.0.0.0,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers,Version=1.0.0.0,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc,Version=3.0.0.0,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages,PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
<uri>
<!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names),which is necessary for OpenID urls with unicode characters in the domain/host name.
It is also required to put the Uri class into RFC 3986 escaping mode,which OpenID and OAuth require. -->
<idn enabled="All" />
<iriParsing enabled="true" />
</uri>
<system.net>
<defaultProxy enabled="true" />
<settings>
<!-- This setting causes .NET to check certificate revocation lists (CRL)
before trusting HTTPS certificates. But this setting tends to not
be allowed in shared hosting environments. -->
<!--<servicePointManager checkCertificateRevocationList="true"/>-->
</settings>
</system.net>
<dotNetOpenAuth>
<!-- This is an optional configuration section where aspects of dotnetopenauth can be customized. -->
<!-- For a complete set of configuration options see http://www.dotnetopenauth.net/developers/code-snippets/configuration-options/ -->
<openid>
<relyingParty>
<security requireSsl="false" />
<behaviors>
<!-- The following OPTIONAL behavior allows RPs to use SREG only,but be compatible
with OPs that use Attribute Exchange (in various formats). -->
<add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform,DotNetOpenAuth" />
</behaviors>
</relyingParty>
</openid>
<messaging>
<untrustedWebRequest>
<whitelistHosts>
<!-- Uncomment to enable communication with localhost (should generally not activate in production!) -->
<!--<add name="localhost" />-->
</whitelistHosts>
</untrustedWebRequest>
</messaging>
<!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
<reporting enabled="true" />
</dotNetOpenAuth>
</configuration>
更新: 您可以实现自定义资源检索提供程序: public class CustomResourceProvider : IEmbeddedResourceRetrieval
{
public Uri GetWebResourceUrl(Type someTypeInResourceAssembly,string manifestResourceName)
{
return new Uri("http://www.google.com");
}
}
然后在web.config中注册它: <dotNetOpenAuth>
<webResourceUrlProvider type="AppName.CustomResourceProvider,AppName" />
...
</dotNetOpenAuth>
但我建议您使用openid-selector库生成登录表单. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 从_layout.cshtml将常量值传递给Angular
- asp.net-mvc – 如何在ASP.NET MVC w / VB.NET中添加id HTM
- asp.net-mvc – MVC获得管理层批准
- asp.net – 如何在Linux服务器上安装mono?
- 防止IIS卸载ASP.Net站点
- asp.net-mvc-3 – 创建MVC3剃刀助手,如Helper.BeginForm()
- 基于asp.net MVC 应用程序的生命周期(详解)
- ASP.NET C#将用户添加/更新到角色
- asp.net – Glass Mapper打破了图像字段的标准值
- asp.net – C# – 一次将多个记录插入AS400
推荐文章
站长推荐
- asp.net – 如何在C#中获取特定文件夹的总大小?
- asp.net – 全局ASAX中的错误:文件不存在
- c# dynamic动态类型和匿名类
- asp.net – 通过http将数据从服务器推送到浏览器
- asp.net-mvc – 向MVC ModelMetadata添加新属性
- asp.net-mvc – 带有MVC 3文件上传的空Request.F
- asp.net-mvc – 在ASP.NET MVC组织帐户中访问Azu
- asp.net – 获取ListView中动态添加的控件的值
- asp.net – REST服务的成员资格/授权
- asp.net-mvc – ASP.NET MVC 3列表到IEnumerable
热点阅读
