StrataFrame Forum

How do I pass parameters to a web form without putting them in the querystring?

http://forum.strataframe.net/Topic30770.aspx

By Marcia G Akins - 1/4/2012

Hi all.

This a a very noobie question, but I do mostly winforms development. I need to create a web page that I can send a link to from my winofrms app. I do not want to put something like this:

?pk=1010&user_id=akinsm

in the URL for obvious reasons. My first impulse when I see things like this is to put in different values and see what I can see Smile

So, I am creating my web page using StrataFrame and I just need to know the best way to pass the parameters when I send the link from my winforms app.

TIA

Marcia
By Trent L. Taylor - 1/4/2012

You can do it several ways.  You can use a POST operation instead of a GET.  GET operations expose the query string like you mentioned and is more limited in the length.  If you want to use a GET operation, you can encrypt it using the StrataFrame 3DES class or even create a Base64 output.

Another option is to use session variables between pages.  For example:

Adding a Session Variable
this.Session.Add("MyVariableName", MyValue)


Retrieving a Session Variable
string myValue =  (string)this.Session["MyVariableName"]


Hope this helps get you started.
By Marcia G Akins - 1/4/2012

Trent L. Taylor (1/4/2012)
You can do it several ways.  You can use a POST operation instead of a GET.  GET operations expose the query string like you mentioned and is more limited in the length.  If you want to use a GET operation, you can encrypt it using the StrataFrame 3DES class or even create a Base64 output.


Hi Trent.

Thanks for the speedy response. When I say that I am a noobie at webforms, i mean that I am REALLY a noobie Smile.

Since my winforms app is going to e-mail a link to a single web page on which the e-mail recipient has only to input a couple of fields, I think that the quickest solution may be to encrypt the QueryString.

I will search the StrataFrame docs to see how to use the 3DES class to do this and if I get stuck I will come back here crying for more help.
By Edhy Rijo - 1/4/2012

Marcia G Akins (1/4/2012)
I will search the StrataFrame docs to see how to use the 3DES class to do this and if I get stuck I will come back here crying for more help.

Hi Marcia, here is a quick sample on how to use the SF encryption class: http://forum.strataframe.net/FindPost19605.aspx
By Marcia G Akins - 1/4/2012

[quote]Edhy Rijo (1/4/2012)

Hi Marcia, here is a quick sample on how to use the SF encryption class: http://forum.strataframe.net/FindPost19605.aspx[/quote]

Thanks for the link, Edhy. I will look at it as soon as I get this page laid out and functioning.
By Marcia G Akins - 1/5/2012

Trent L. Taylor (1/4/2012)
You can do it several ways.  You can use a POST operation instead of a GET.  GET operations expose the query string like you mentioned and is more limited in the length.  If you want to use a GET operation, you can encrypt it using the StrataFrame 3DES class or even create a Base64 output.


Hi Trent.

I tried using the 3DES class but when I try to decrypt using this code:

String DecryptedSignOffID = _3des.Decrypt(Request["pk"].ToString());

I wind up with this error instead of the web page:

System.FormatException was unhandled by user code
  Message=Invalid length for a Base-64 char array.
  Source=mscorlib
  StackTrace:
       at System.Convert.FromBase64String(String s)
       at MicroFour.StrataFrame.Security.Encryption.TripleDESWrapper.Decrypt(String text)
       at StlCI_new.EditSignOff.Page_Load(Object sender, EventArgs e) in C:\StlCI_new\StlCI_new\StlCI_new\EditSignOff.aspx.cs:line 25
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:

Now, the goofy thing is that just for grins and giggle, I tried decrypting the value right after I encypted it like so:

string EncrytedSignOffID = _3des.Encrypt(e.BusinessObject["sign_off_id"].ToString());

string DecrytedSignOffID = _3des.Decrypt(EncryptedSignOffID);

and it was happy as a clam. So apparently, there is an issue trying to decrypt the string when it is used as part of a QueryString, but I have absolutely no idea what the problem could be.

Can you help?

TIA

Marcia
By Marcia G Akins - 1/5/2012

Hi all.

I finally got this figured out. All I needed was this on the Decrypt:

String DecryptedSignOffID = _3des.Decrypt(Request["pk"].Replace(" ", "+"));