Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamic error in asp.net mvc 3.0 razor

I am trying to add some code that I got from 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. 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

Edit 2

They must have changed it. I was checking and my version of dotnetopenauth does not take in 2 parameters only 1.

Nerd dinners version takes in 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. An embedded resource URL provider must be set in your .config file.

like image 331
chobo2 Avatar asked Feb 25 '23 07:02

chobo2


2 Answers

OpenIdSelector is defined as an extension method and you don't have to pass in the first parameter. 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

like image 132
marcind Avatar answered Mar 04 '23 02:03

marcind


The Page property is dynamic, and as such the OpenIdSelector method can't be despatched with a dynamic property. Try casting the Page property:

@Html.OpenIdSelector((Page)this.Page, new SelectorButton[] { ... });
like image 31
Matthew Abbott Avatar answered Mar 04 '23 01:03

Matthew Abbott