开发者

"username" parameter coming back with more than I gave it!

开发者 https://www.devze.com 2023-02-17 03:28 出处:网络
This is really weird - I\'ve got a MVC app running, including a Login method in my ServicesController class:

This is really weird - I've got a MVC app running, including a Login method in my ServicesController class:

public ActionResult Login() {
  var p = Request.Params;
  var userName = p["username"];
  var password = p["password"];
  // etc...
}

The weird thing is that when I call the service with t开发者_StackOverflow社区he request:

/services/login?username=myusername&password=password

I get into the code and find that userName is "anotherusername,myusername". Depending on what browser I'm using, I get different values in place of "anotherusername", which I recognize from some other apps I'm developing. So is "username" some kind of reserved word that one shouldn't use as a parameter name? What other reserved words are there that cannot be used safely as parameters?


Request.Params combines values from Request.QueryString, Request.Form, Request.ServerVariables and Request.Cookies. I would expect that the second value is either a server variable or a cookie. You could find out by checking each collection for your request.

Try checking the Request.QueryString (GET request) or Request.Form (POST request) instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消