Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MVC MVC3
I am using MVC3. I have a couple of pages which do not require authentication but these pages have querystrings which could be tampered. These pages are for info collection forms for guests which do not need to be authenticated. I am planning to encrypt these urls when sending to users and decrypt it back when they hit it, what is the best way to encrypt and decrypt query strings in MVC3 or is there any other solution for such scenario?
 
Send me a pointer If there is any module that I can reuse...
 
Appreciate your help
 
Thanks
Posted 21-May-12 7:51am
Edited 21-May-12 14:34pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If it was me I would just serialize the form and call the controller method with AJAX. If you do a post the query string won't be visible to the user. After the AJAX call is successful you can forward them on to the next page you want them on. I have included some example code to do use this method.
 
var formInfo = $("#FormName").serialize();
$.ajax({
        type: "POST",
        url: "ControllerMethod",
        data: formInfo,
        error: function (xhr, ajaxOptions, thrownError) {
             //Code to handle an error
        },
        success: function (data) {
             //Code to do what ever you want once successfully uploaded.        
        }    
});

 
Other than that I am not sure of a way to encrypt the URL. The browser needs to be able to interpret the URL to know which page to go to so I don't think this will be possible. But I could be wrong.
 
You could also encrypt the individual values then pass them in the URL that way. That would take a lot of work though. You would need to call a method on the server to encrypt each value entered than store the encrypted value in the form some where. The reason I say to encrypt on the server is because client side code is downloaded to the computer so anyone would have access to it and see how you were doing the encryption.
 
Hope this helps.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 329
2 CPallini 270
3 DamithSL 214
4 Maciej Los 192
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 11 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100