views:

67

answers:

2

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();
}
A: 

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

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

Hector
A: 

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));
Johan Olsson