1

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

2 Answers 2

1

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));
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.