In my MVC application i want to encrypt and decrypt data in data transmission from view to Controller . How to do this in MVC 4 using Razor ?
-
1Why not just use SSL? – Floremin Apr 02 '13 at 14:19
-
Type https:// instead of http://? – Lars Apr 02 '13 at 14:19
-
1What do you mean by data transmission from View to Controller? – Yuriy Faktorovich Apr 02 '13 at 14:19
-
suppose i am sending an id from my view to my controller and i want to encrypt this id ? – Ankur Tripathi Apr 02 '13 at 14:21
2 Answers
You don't need to encrypt data from the controller to the view since the view rendering happens in the same computer that the controller is operating.
If you want to encrypt the page that is sent to the user you should use a ssl connection

- 1,244
- 1
- 15
- 28
-
-
It is not possible without SSL because your client computer should have a way to know how to decript the information that you send. – Gabriel Monteiro Nepomuceno Apr 02 '13 at 14:23
-
If this is a valid answer for you could you please mark it as answered? – Gabriel Monteiro Nepomuceno Apr 02 '13 at 14:24
based on this comment: "suppose i am sending an id from my view to my controller and i want to encrypt this id ?"
if you want to encrypt the "id" in a view, in this case you already have the "id" in the view, "id" would be generated in the database or other but not in the client.
In this case, you can encrypt the "id" after put it on the client, and then the controller decrypt only the "id".
Here you have an example that encrypts only the "id", this is done for security so that data is not looking for "id".
In this case you have to encrypt and decrypt the property:
https://stackoverflow.com/a/14774470/138071
http://amitpatelit.com/2011/08/08/url-encryption-in-mvc-application/
In this example (in Spanish) does for all parameters that are received with an underscore (_):

- 1
- 1

- 14,887
- 13
- 64
- 115