c# - Model binding in ASP.NET Core to map underscores to title case property names -
i have model class want bind query string in asp.net mvc core (rc2) application.
i need support underscores in query string keys confirm oauth specs, want work title case property names in application.
my model class looks this:
class oauthparameters { public string clientid {get; set;} public string responsetype {get; set;} public string redirecturi {get; set;} }
so i'd bind query strings client_id
, response_type
, redirect_uri
it.
is there way asp.net mvc core automagically or through attribute annotation?
i've read articles writing custom model binders, these seem (1) overly complex i'm trying achieve , (2) written rc1 or earlier in mind , of syntax has changed.
thanks in advance.
you can use fromquery
attribute's name
property here.
example:
public class oauthparameters { [fromquery(name = "client_id")] public string clientid { get; set; } [fromquery(name = "response_type")] public string responsetype { get; set; } [fromquery(name = "redirect_uri")] public string redirecturi { get; set; } }
Comments
Post a Comment