简体   繁体   English

asp.net mvc 3.0 razor中的动态错误

[英]dynamic error in asp.net mvc 3.0 razor

I am trying to add some code that I got from nerdinner 我想添加一些我从nerdinner得到的代码

  @Html.OpenIdSelector(this.Page, new SelectorButton[] 
     {
        new SelectorProviderButton("https://me.yahoo.com/", Url.Content("~/Content/Images/Account/Index/yahoo_64.png")),
        new SelectorProviderButton("https://www.google.com/accounts/o8/id", Url.Content("~/Content/images/google.gif")),
        new SelectorOpenIdButton(Url.Content("~/Content/images/openid.gif")),
    }) 

however I get this error 但是我得到了这个错误

Error 1 'System.Web.Mvc.HtmlHelper' has no applicable method named 'OpenIdSelector' but appears to have an extension method by that name. 错误1'System.Web.Mvc.HtmlHelper'没有名为'OpenIdSelector'的适用方法,但似乎有一个名称的扩展方法。 Extension methods cannot be dynamically dispatched. 无法动态分派扩展方法。 Consider casting the dynamic arguments or calling the extension method without the extension method syntax. 考虑转换动态参数或调用扩展方法而不使用扩展方法语法。

I have no clue what it wants. 我不知道它想要什么。

Edit 编辑

I get this now 我现在明白了

CS1928: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'OpenIdSelector' and the best extension method overload 'DotNetOpenAuth.Mvc.OpenIdHelper.OpenIdSelector(System.Web.Mvc.HtmlHelper, params DotNetOpenAuth.OpenId.RelyingParty.SelectorButton[])' has some invalid arguments CS1928:'System.Web.Mvc.HtmlHelper'不包含'OpenIdSelector'的定义和最佳扩展方法重载'DotNetOpenAuth.Mvc.OpenIdHelper.OpenIdSelector(System.Web.Mvc.HtmlHelper,params DotNetOpenAuth.OpenId.RelyingParty。 SelectorButton [])'有一些无效的参数

Edit 2 编辑2

They must have changed it. 他们肯定已经改变了。 I was checking and my version of dotnetopenauth does not take in 2 parameters only 1. 我正在检查,我的dotnetopenauth版本只接受2个参数1。

Nerd dinners version takes in 2. 书呆子晚餐版本需要2。

Anyways now I removed that and get this 无论如何,现在我删除了它并得到它

Server Error in '/' Application. '/'应用程序中的服务器错误。 The current IHttpHandler is not one of types: System.Web.UI.Page, DotNetOpenAuth.IEmbeddedResourceRetrieval. 当前的IHttpHandler不是以下类型之一:System.Web.UI.Page,DotNetOpenAuth.IEmbeddedResourceRetrieval。 An embedded resource URL provider must be set in your .config file. 必须在.config文件中设置嵌入式资源URL提供程序。

OpenIdSelector is defined as an extension method and you don't have to pass in the first parameter. OpenIdSelector被定义为扩展方法,您不必传入第一个参数。 Instead you call it like this: 相反,你这样称呼它:

@Html.OpenIdSelector(new SelectorButton[] {...})

This is equivalent to the following call: 这相当于以下调用:

@OpenIdHelper.OpenIdSelector(this.Html, new SelectorButton[] {...})

For the second Edit to your question, looks like this might help: InvalidOperationException thrown regarding DotNetOpenAuth.IEmbeddedResourceRetrieval with Razor view 对于您的问题的第二个编辑,看起来这可能会有所帮助: 针对具有Razor视图的DotNetOpenAuth.IEmbeddedResourceRetrieval抛出InvalidOperationException

The Page property is dynamic, and as such the OpenIdSelector method can't be despatched with a dynamic property. Page属性是动态的,因此无法使用动态属性发送OpenIdSelector方法。 Try casting the Page property: 尝试转换Page属性:

@Html.OpenIdSelector((Page)this.Page, new SelectorButton[] { ... });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM