Return to ASP.NET session from external redirect

I have redirected to an external site from an asp.net application supplying a return URL of the last asp.net page I was on. How can I get all the values back( shoppingbasket, user, session?) and continue processing as if I had never left the page?
JamesJMcDonnellAsked:
Who is Participating?
 
j-w-thomasCommented:
Since there is no specific method or class or pre-built solution for this, and if you really need this to function this way, this is what I would do:

Usually the payment site will allow you to carry several pieces of info to them for processing. PayPal has fields that are customizable and that carry into the PayPal authorization and PayPal can send back some (it has been a while since I worked with PayPal) informaiton via a querystring.

If one unique identfier could be passed to AND back from PayPal (or whoever) then you can use that to recall all settings that were initiallly on site 1 and that you can save all settings to a db table and use the unique identifier in the initlal INSERT and then again to recall it on Page_Load.

In other words, just before the re-direct, save all of the settings to a db and assign a unique identifier. Pass that identifier to the payement site and pass it back as well. Upon loading the page from the payment site, use the identifier to recall info/settings from the db.

1) Does that idea make sense?
2) Can you pass a unique identifier both ways with whatever payment site you are using?

I do worry about security, depending on what you are recalling...

Hope this helps...

John
0
 
GawaiCommented:
save the data in cookies and get it back
0
 
j-w-thomasCommented:
The other option, though possibly too simplistic is to open the new site in a new window and then all session info from your main site is preserved...

John
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
JamesJMcDonnellAuthor Commented:
I'm not sure that opening the other site in a new window is really an option. I need to post values to the other site and receive values back. The other site is checking authorization on a credit card and needs to post values back. On my site I need to keep track of a shopping basket and update payment details and payment history after returning from redirection. I don't think cookies are a god option because the client may have cookies switched off. Another issue is knowing on the page that it has come back from a redirection. Do I need to suply a querystring value in the return url?
0
 
j-w-thomasCommented:
Yes a querystring will work as long as it does not contain sensitive information, as I am sure that you already know.

Then read the querystring on Page_Load of the main site's receiving page...

John
0
 
JamesJMcDonnellAuthor Commented:
Yes, the quertstring could just indicate that the asp.net page was redirected back to. However, how to get firstly any values posted back by the other site and secondly values for current site?
0
 
JamesJMcDonnellAuthor Commented:
Yes the idea makes sense. Unique values are being passed each way, but how can I access the posted back values?
0
 
JamesJMcDonnellAuthor Commented:
The other site is posting the values back not sending them in a querystring
0
 
j-w-thomasCommented:
Sorry, how does the other site send them back to you? Normally it is in a querystring, I may have misunderstood your last comment...
0
 
j-w-thomasCommented:
Remember you only need one unique value that you sent, say an INVOICE # and then if possible the other site would use that same invoice number when they re-direct back to you. Is that possible?
0
 
JamesJMcDonnellAuthor Commented:
They (a credit card issuer) send two values back called MD and PaRes which need to be subseqently used in a web request to another company's webservice. They post the values back to a web page whose url was one of the bits of information posted to them by a redirect. I think they need to return the values to fidden fields in the page they are posted back to. However I also think they need the field names to be named MD and PaReq. However the asp.net of course changes the names to _ctl3:MD and _ctl3:PaRes so have not got this working yet.
0
 
j-w-thomasCommented:
What if you create a special "landing page" where the user is returned to and then you can gather the infor from the fields where the payment site puts them, and the n put a single, large button on the "landing page" labeled "Return to your previous page".

Upon a click the values will be in known controls on the "landing page" and easily accessed.

Further, you could make the landing pagew have an automatic re-direct in the HTML code...no clicking necessary, just a message to the user that you will be re-directed back to your initla page in 5 seconds (type of thing...)
0
 
JamesJMcDonnellAuthor Commented:
It turns out that the session is maintained during the redirection and only a few values need maintaining in session state. Using a querystring is used to take control back when the values are posted back. Getting the posted back values is accomplished by accessing the request object. The code I use in page_load is:
if (Request.QueryString["redirect"] == "y")
{
        string MD = Request["MD"];
        string PaRes = Request["PaRes"];
       lblCardNumber.Text = Session["cardNumber"].ToString();
       FinishConfirmOrder(MD, PaRes);
}

I guess the only issue is the card number being saved in session state, not sure if that could be a security issue.
0
 
j-w-thomasCommented:
So are you able to do all that you wanted??
0
 
JamesJMcDonnellAuthor Commented:
yes, thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.