开发者

Encoding of URL paramaters

I got a page that is a callback page, when the user gets redirected to my page I hash the parameters and check if it is valid. My problem is when myParameter contains characters like å, ä and ö. If I change myParameter to "same value with åäö" in the 开发者_开发技巧controller, then it works.

I believe it has something to do with encodings, and I have looked at several solutions with conversion of encoding, but none of them have solved my problem.

You got any bright ideas?

public ActionResult MyCallback(string myParameter, string myMAC)
{
    // This works...
    myParameter = "same value with åäö";

    if(Hash(myParameter + mySecrect).Equals(myMAC))
    {
        // Valid.
    }

    return View();
}


I solved it by getting the parameter from the URL and decode it myself.

Regex regex = new Regex(@"foo=(.*?)(&|\z)");
string myFooParameter = regex.Match(Request.RawUrl).Groups[1].Value;
myFooParameter = HttpUtility.UrlDecode(myFooParameter, Encoding.GetEncoding(28591));


Are you sure the problem is now with your Hash routine?

Can you calculate the Hash with the problematic value outside of MVC?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜