billbogaiv/hybrid-model-binding

Is `name:` supposed to allow binding to different value names?

dynajoe opened this issue · 2 comments

I'm trying to bind a model that looks like this:

   public class AccessTokenRequest
   {
      [HybridBindProperty(new[] { Source.QueryString, Source.Form }, name: "grant_type")]
      public string GrantType { get; set; }

      [HybridBindProperty(new[] { Source.QueryString, Source.Form }, name: "redirect_uri")]
      public Uri Redirecturi { get; set; }

   }

It doesn't seem that GrantType is using the grant_type parameter name. Am I misunderstanding the purpose of name?

Am I misunderstanding the purpose of name?

No.

Do you have a sample available or a snippet I can look at?

You could play around with the sample project and modify IndexModel:

[HybridBindProperty(new[] { Source.Body, Source.Form, Source.QueryString, Source.Route })]
. Give the attribute a name like test-name and then submit a request like: http://localhost:12512/10/bill?test-name=William. The response should look like:

<h3>Age: 10</h3>
<h3>Name: William</h3>

IndexModel.cs

[HybridBindProperty(new[] { Source.Body, Source.Form, Source.QueryString, Source.Route }, name: "test-name")]
public string Name { get; set; }

Closing due to inactivity. Feature works as-expected.