Query String Encryption problem while postback events in asp.net 3.5
Query String Encryption is getting while navigating . But while postback the q开发者_开发技巧uery string data will be decrypted . Suggest me how to keep the encrypted data as it is
I am not sure if this will 100% work but i was wondering if you can replace the query string entirely and access those properties straight out of the previous page.
If you create public properties inside the page you are transferring from, say Property1 and Property2 (both of which are strings) then:
if(!IsPostBack)
{
T previousPage = (T)this.Page.PreviousPage;
string firstParameter = previousPage.Property1;
string secondParameter = previousPage.Property2;
}
where T is the type of the first page you are transferring from. This would eliminate the need for the query string and encryption entirely?
Unless of course you are doing ajax calls from javascript that require encrypted parameters?
Before redirecting your user, encrypt the querystring parameters one by one and decrypt them one by one on the page you redirect.. You can find tons of encription libraries on the net. You can store these values in session and load the session only if the Page.IsPostBack is false, if it is true, load the parameters back from the Session.
精彩评论