Tony
Tony

Reputation: 12695

ASP.NET MVC A problem with passing an encrypted string to the controller's action

let's way that one of my controller's action gets - as a parameter - an encrypted string. A problem is, that when the URL looks

MyAccount/Activate/?code=DbXQ2SQiwYYiDhC+ahAppa23P95YifE2z6uyvnhWCFE=

the 'code' parameter in that action looks like:

DbXQ2SQiwYYiDhC ahAppa23P95YifE2z6uyvnhWCFE=

(the "+" char is missing)

why ?

Upvotes: 1

Views: 573

Answers (2)

Spencer Ruport
Spencer Ruport

Reputation: 35117

URLs are URL encoded and + is interpreted as a space. Use the Server.UrlEncode() method to encode your encrypted string prior to passing it through the querystring.

Or if this encrypted string is coming from the client side you'll need to use javascript to encode the data. I'm sure there's dozens of articles about the web on how to do this. Here's one example: http://plugins.jquery.com/project/URLEncode

Upvotes: 3

villecoder
villecoder

Reputation: 13483

You need to URL encode the code parameter in the GET string. It should be

MyAccount/Activate/?code=DbXQ2SQiwYYiDhC%2bahAppa23P95YifE2z6uyvnhWCFE%3d

Upvotes: 1

Related Questions