?
Solved

Return to ASP.NET session from external redirect

Posted on 2007-10-15
15
Medium Priority
?
581 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:JamesJMcDonnell
  • 7
  • 7
15 Comments
 
LVL 20

Expert Comment

by:Gawai
ID: 20080172
save the data in cookies and get it back
0
 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20080582
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
 

Author Comment

by:JamesJMcDonnell
ID: 20084170
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20084621
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
 

Author Comment

by:JamesJMcDonnell
ID: 20084913
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
 
LVL 3

Accepted Solution

by:
j-w-thomas earned 1500 total points
ID: 20085001
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
 

Author Comment

by:JamesJMcDonnell
ID: 20086041
Yes the idea makes sense. Unique values are being passed each way, but how can I access the posted back values?
0
 

Author Comment

by:JamesJMcDonnell
ID: 20086190
The other site is posting the values back not sending them in a querystring
0
 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20086679
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
 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20086693
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
 

Author Comment

by:JamesJMcDonnell
ID: 20086818
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
 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20088209
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
 

Author Comment

by:JamesJMcDonnell
ID: 20100973
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
 
LVL 3

Expert Comment

by:j-w-thomas
ID: 20104709
So are you able to do all that you wanted??
0
 

Author Comment

by:JamesJMcDonnell
ID: 20108736
yes, thanks for your help
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question