c# - Model not binding on RedirectToRoute -


i've scoured , down answer thought common problem, haven't been able find solution... here's question:

i have following model:

public class usermodel     {         public string usertype { get; set; }         public string username { get; set; }         public string password { get; set; }         public string userclaim { get; set; }         public string redirectaction { get; set; }         public string jsonwebtoken { get; set; }         public string message { get; set; }      } 

i'm "populating" model in web api controller:

return redirecttoroute("default", new             {                 controller = "redirect",                 action = "ssoredirect",                 method = "get",                 usertype = thisuser.usertype,                 username = thisuser.username,                 password = thisuser.password,                 userclaim = thisuser.userclaim,                 redirectaction = thisuser.redirectaction,                 jsonwebtoken = thisuser.jsonwebtoken,                 message = thisuser.message,              }); 

then passing controller so:

[httpget] [route("ssoredirect")]      public ihttpactionresult ssoredirect(usermodel myuser) {     .... } 

the problem: myuser coming through null. none of properties on model being bound.

here's i've made sure of:

  1. my routing good, because breakpoint in ssoredirect in fact being hit.
  2. when trace in fiddler can see appropriate query string params being passed.
    1. i understand can't pass complex objects enums , other complex data types limited strings.

so... life of me can't figure out why model isn't binding , hoping here.

if you're taking complex type in parameter web api controller , accessing via get, need tell controller can create object querystring parameters sent across in request. add [fromuri] attribute , object should created fine:

[httpget] [route("ssoredirect")]      public ihttpactionresult ssoredirect([fromuri]usermodel myuser) {     .... } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -