Connecting Tech Pros Worldwide Forums | Help | Site Map

passing variable from asp.net to asp

Newbie
 
Join Date: Oct 2009
Posts: 12
#1: Oct 13 '09
Desperately need help....

here's the snippet of my code that im trying to solve since last week...

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. If (Left(Request.Form("return_url"), 7) <> "http://") Then 
  2.   errorInput = errorInput & "Invalid return URL path! <BR>" 
  3.   errorExist = True 
  4.   Response.Redirect("InvalidUrlError.aspx")
  5. Else 
  6.  Session( "res") = "1" 
  7.   TextBox2.Text = Session(Response.Redirect(Request.Form("res")"retu rn_url"))
payResult.asp
Expand|Select|Wrap|Line Numbers
  1. <% if ( Request.QueryString(Session("res") ) = "1") then %>
  2.   Thanks!
  3. <% else %>
  4.   sorry
  5. <% end if %> 
However,it could not be captured in payResult.asp

Ive tried using Request.form(Session("res"), Session("res") in payResult.asp but still it doesnt work...

CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#2: Oct 13 '09

re: passing variable from asp.net to asp


Hello Ryna,

If I understand your question/problem you have a scenario where your user is on a dotNet page and you want to redirect them to a Classic asp page and also pass in a variable to the Classic asp page too?

If that’s the case then pass the variable within the query string like this:

Expand|Select|Wrap|Line Numbers
  1. Response.Redirect("payResult.asp?res=" & Session("res"))
  2.  

Hope that helps,
CroCrew~
Newbie
 
Join Date: Oct 2009
Posts: 12
#3: Oct 14 '09

re: passing variable from asp.net to asp


hi crowcrew...

its not working...it shows page error(The page cannot be displayed)

=(
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#4: Oct 14 '09

re: passing variable from asp.net to asp


Hello ryna,

So, I/we understand the situation better could you please post the code for both the pages? A 404 (page cannot be displayed) could be many things.

But, please before pasting your code for each page make sure you wrap the code of each page inside [code] tags.

Thanks,
CroCrew~
Newbie
 
Join Date: Oct 2009
Posts: 12
#5: Oct 14 '09

re: passing variable from asp.net to asp


Here's the code..

icePayment.aspx

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3.  
  4. Partial Class icePayment
  5.     Inherits System.Web.UI.Page
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  8.  
  9.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")
  10.         conn.Open()
  11.  
  12.         Dim response_text As String
  13.         'Dim redirectStr As String
  14.         Dim input(9) As Object
  15.         Dim errorInput As String
  16.         Dim errorExist As Boolean
  17.         Dim inputName As Object  ' Object
  18.         Dim i As Integer
  19.         Dim j As Integer
  20.         Dim k As Integer
  21.  
  22.         errorInput = ""
  23.         errorExist = False
  24.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}
  25.  
  26.         'get input from Form
  27.         For i = 0 To 8
  28.             Input(i) = Request.Form(inputName(i))
  29.         Next
  30.         'Check the Input is Empty
  31.         For j = 0 To 8
  32.             If IsNothing(Input(j)) Then
  33.                 errorInput = errorInput & inputName(j) & " is blank.<BR>"
  34.                 errorExist = True
  35.             End If
  36.         Next
  37.         'Check the Input is Numeric
  38.         For k = 0 To 5
  39.             If Not (IsNumeric(Input(k))) Then
  40.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>"
  41.                 errorExist = True
  42.             End If
  43.         Next
  44.         If Not (errorExist) Then
  45.  
  46.         End If
  47.  
  48.         Dim response_code As Integer
  49.         'Dim Msg As String
  50.  
  51.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)
  52.  
  53.         Dim merchant As String = Request.Form("merchant_id")
  54.         Dim merchantDr As SqlDataReader
  55.         merchantDr = merchantSql.ExecuteReader()
  56.  
  57.  
  58.         response_code = 0
  59.         If merchantDr.Read() Then
  60.             response_code = 0
  61.  
  62.             If merchant <> Trim(merchantDr("merchantID")) Then
  63.                 response_text = "Invalid Merchant ID"
  64.                 'Response.Redirect("MerchantError.aspx")
  65.             End If
  66.  
  67.         Else
  68.         End If
  69.         merchantDr.Close()
  70.         conn.Close()
  71.  
  72.         conn.Open()
  73.         Dim credit As String = Trim(Request.Form("card_num"))
  74.         Dim cardName As String = Trim(Request.Form("card_name"))
  75.         Dim cardType As String = (Request.Form("card_type"))
  76.         'Dim cardType As String = CDbl(Request.Form("card_type")) / 1
  77.         Dim amount As String = Trim(Request.Form("amount"))
  78.         Dim ref_code As String = Trim(Request.Form("ref_code"))
  79.         Dim desc As String
  80.         Dim time As Date
  81.         Dim randomNo As Single
  82.         Dim trans_date As String
  83.         Dim trans_code As String
  84.         Dim expireMonSql As Integer
  85.         Dim expireYrSql As Integer
  86.         Dim credit_limit As Object
  87.         Dim total_credit As Object
  88.         Dim credit_balance As Object
  89.         Dim merchant_balance As Object
  90.         Dim userID As Object
  91.         Dim mBalance As Object
  92.         Dim debit_account As Object
  93.         Dim credit_account As Object
  94.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))
  95.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))
  96.         'Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance  FROM iceUser INNER JOIN (  account_summary INNER JOIN iceCredit   ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Request.Form("card_num") & "' ", conn)
  97.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn)
  98.         'Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID ", conn)
  99.  
  100.         Dim creditDr As SqlDataReader
  101.         creditDr = creditSql.ExecuteReader()
  102.  
  103.         If creditDr.Read() Then
  104.             response_code = 0
  105.  
  106.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then
  107.                 response_text = "Invalid Credit Card No"
  108.  
  109.             Else
  110.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then
  111.                     response_text = "Invalid Card Holder's Name"
  112.  
  113.                     ' Label1.Text = cardName & Trim(UCase(creditDr("fullName")))
  114.                 Else
  115.                     'If cardType <> CDblcreditDr("cardType")) / 1 Then
  116.                     If cardType <> (creditDr("cardType")) Then
  117.                         response_text = "Invalid Card Type"
  118.  
  119.  
  120.                     Else
  121.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))
  122.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))
  123.                         credit_limit = Trim(creditDr("creditLimit"))
  124.                         total_credit = Trim(creditDr("totalCredit"))
  125.  
  126.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then
  127.                             response_text = "Invalid Credit Card"
  128.  
  129.  
  130.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then
  131.                             response_text = "Card limit is reached!"
  132.  
  133.                         Else
  134.                             response_code = 1
  135.                             credit_balance = Trim(creditDr("creditBalance"))
  136.                             debit_account = Trim(creditDr("creditCardNo"))
  137.                             credit_account = Trim(creditDr("merchantID"))
  138.                             merchant_balance = Trim(creditDr("merchantBalance"))
  139.                             userID = Trim(creditDr("userID"))
  140.  
  141.  
  142.                             If (response_code = 1) Then
  143.  
  144.                                 If (CInt(credit_balance) = 0) Then
  145.                                     credit_limit = CDbl(credit_limit) - CDbl(amount)
  146.                                     credit_balance = -CDbl(amount)
  147.  
  148.                                 Else
  149.                                     credit_balance = CDbl(credit_balance) - CDbl(amount)
  150.  
  151.  
  152.                                     If (credit_balance >= 0) Then
  153.                                         credit_limit = total_credit
  154.  
  155.                                     Else
  156.                                         credit_limit = total_credit + credit_balance
  157.  
  158.                                     End If
  159.                                 End If
  160.  
  161.                                 'mBalance = merchant_balance
  162.                                 'mBalance = mBalance + CDbl(amount)
  163.                                 'conn.Close()
  164.                                 'conn.Open()
  165.  
  166.                                 ''update merchant balance
  167.                                 'Dim updateMerchant As String
  168.                                 'updateMerchant = "update iceMerchant set merchantBalance = '" & mBalance & "' where merchantID = '" & merchant & "'"
  169.                                 'Dim cmdMerchant As New SqlCommand(updateMerchant, conn)
  170.                                 'cmdMerchant.ExecuteNonQuery()
  171.  
  172.                                 'conn.Close()
  173.                                 'conn.Open()
  174.  
  175.                                 ''edit iceCredit table
  176.                                 'Dim updateCredit As String
  177.                                 'updateCredit = "update iceCredit set creditBalance = '" & credit_balance & "',creditLimit = '" & credit_limit & "' where creditCardNo ='" & credit & "'  "
  178.  
  179.                                 'Dim cmdCredit As New SqlCommand(updateCredit, conn)
  180.                                 'cmdCredit.ExecuteNonQuery()
  181.  
  182.  
  183.                                 'Randomize(Timer())
  184.                                 'randomNo = 0
  185.                                 'Do While randomNo <= 1000
  186.                                 '    randomNo = Int((9999 * Rnd()) + 1)
  187.                                 'Loop
  188.                                 'time = TimeOfDay()
  189.                                 'trans_date = Today() & " " & TimeOfDay()
  190.                                 'trans_code = "ICE-"
  191.                                 'trans_code = trans_code & randomNo & Second(time) & "-" & Int(Timer())
  192.                                 'Dim c1 As String = "Credit Card Transaction @"
  193.                                 'Dim c2 As String = "</BR> Ref. Code: "
  194.                                 'desc = c1 & time & c2 & ref_code
  195.  
  196.                                 'conn.Close()
  197.                                 'conn.Open()
  198.  
  199.                                 ''insert(transaction)
  200.                                 'Dim updateTrans As String
  201.                                 'updateTrans = "insert into iceTransaction(trans_code, account_id, trans_amt, trans_date, trans_desc,tID) values ('" & trans_code & "','" & debit_account & "', '" & amount & "','" & trans_date & "','" & desc & "','" & userID & "')"
  202.  
  203.                                 'Dim cmdTrans As New SqlCommand(updateTrans, conn)
  204.                                 'cmdTrans.ExecuteNonQuery()
  205.                                 ''Request.Form("response_code") = 1
  206.                                 'response_text = "Transaction is success!!"
  207.                                 ''redirectStr = Request.Form("return_url")
  208.  
  209.                             End If
  210.  
  211.                         End If
  212.  
  213.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then
  214.                             errorInput = errorInput & "Invalid return URL path! <BR>"
  215.                             errorExist = True
  216.                             Response.Redirect("inputerror.aspx")
  217.                             Response.Redirect("InvalidUrlError.aspx")
  218.                         Else
  219.  
  220.                             Session("res") = response_code
  221.                             Session("text") = response_text
  222.                           Response.Redirect((Request.Form("return_url")))
  223.                         End If
  224.  
  225.                         If (errorExist) Then
  226.                             response_code = 0
  227.                             response_text = errorInput
  228.                         End If
  229.                     End If
  230.  
  231.                 End If
  232.  
  233.             End If
  234.  
  235.         End If
  236.         'End If
  237.  
  238.  
  239.         creditDr.Close()
  240.         conn.Close()
  241.  
  242.     End Sub
  243.  
  244. End Class
  245.  
  246.  
payResult.asp

Expand|Select|Wrap|Line Numbers
  1. <% if ( Request.Form(Session("res")) = 1) then %>
  2.              Thank You for buying GOODS from our online Store!
  3.  
  4.              <% else %>
  5.              I'm sorry,but there was a problem with this transaction.<br />
  6.              The server response was:<br />
  7.  
  8.              <% = Request.Form(Session("text")) %> <br />
  9.              Go back to check Out page to enter information again<br />
  10.  
  11. <% end if %> 
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#6: Oct 14 '09

re: passing variable from asp.net to asp


There is no code that is redirecting to PayResult.asp

is that comming in form the Request.Form("return_url")?

Before the "Dim conn" line in your Page_Load add the following code:

Expand|Select|Wrap|Line Numbers
  1. Response.Write("Here: " & Request.Form("return_url")) 
  2.  
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#7: Oct 14 '09

re: passing variable from asp.net to asp


What do you get before the post and then what do you get after the post.
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#8: Oct 14 '09

re: passing variable from asp.net to asp


Comment out the Response.Redirects on the page too so you don’t get the error
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#9: Oct 14 '09

re: passing variable from asp.net to asp


Hello ryna,

Try substituting your code in “icePayment.aspx” with this code and run your solution and tell us what you get.

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data 
  2. Imports System.Data.SqlClient 
  3.  
  4. Partial Class icePayment 
  5.     Inherits System.Web.UI.Page 
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
  8.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true") 
  9.         conn.Open() 
  10.  
  11.         Dim response_text As String 
  12.         Dim input(9) As Object 
  13.         Dim errorInput As String 
  14.         Dim errorExist As Boolean 
  15.         Dim inputName As Object 
  16.         Dim i As Integer 
  17.         Dim j As Integer 
  18.         Dim k As Integer 
  19.  
  20.         errorInput = "" 
  21.         errorExist = False 
  22.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"} 
  23.  
  24.         For i = 0 To 8 
  25.             Input(i) = Request.Form(inputName(i)) 
  26.         Next 
  27.  
  28.         For j = 0 To 8 
  29.             If IsNothing(Input(j)) Then 
  30.                 errorInput = errorInput & inputName(j) & " is blank.<BR>" 
  31.                 errorExist = True 
  32.             End If 
  33.         Next 
  34.  
  35.         For k = 0 To 5 
  36.             If Not (IsNumeric(Input(k))) Then 
  37.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>" 
  38.                 errorExist = True 
  39.             End If 
  40.         Next 
  41.  
  42.         Dim response_code As Integer 
  43.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn) 
  44.  
  45.         Dim merchant As String = Request.Form("merchant_id") 
  46.         Dim merchantDr As SqlDataReader 
  47.         merchantDr = merchantSql.ExecuteReader() 
  48.  
  49.         response_code = 0 
  50.         If merchantDr.Read() Then 
  51.             response_code = 0 
  52.             If merchant <> Trim(merchantDr("merchantID")) Then 
  53.                 response_text = "Invalid Merchant ID" 
  54.             End If 
  55.         End If 
  56.         merchantDr.Close() 
  57.         conn.Close() 
  58.  
  59.         conn.Open() 
  60.         Dim credit As String = Trim(Request.Form("card_num")) 
  61.         Dim cardName As String = Trim(Request.Form("card_name")) 
  62.         Dim cardType As String = (Request.Form("card_type")) 
  63.         Dim amount As String = Trim(Request.Form("amount")) 
  64.         Dim ref_code As String = Trim(Request.Form("ref_code")) 
  65.         Dim desc As String 
  66.         Dim time As Date 
  67.         Dim randomNo As Single 
  68.         Dim trans_date As String 
  69.         Dim trans_code As String 
  70.         Dim expireMonSql As Integer 
  71.         Dim expireYrSql As Integer 
  72.         Dim credit_limit As Object 
  73.         Dim total_credit As Object 
  74.         Dim credit_balance As Object 
  75.         Dim merchant_balance As Object 
  76.         Dim userID As Object 
  77.         Dim mBalance As Object 
  78.         Dim debit_account As Object 
  79.         Dim credit_account As Object 
  80.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon"))) 
  81.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr"))) 
  82.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn) 
  83.  
  84.         Dim creditDr As SqlDataReader 
  85.         creditDr = creditSql.ExecuteReader() 
  86.  
  87.         If creditDr.Read() Then 
  88.             response_code = 0 
  89.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then 
  90.                 response_text = "Invalid Credit Card No" 
  91.             Else 
  92.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then 
  93.                     response_text = "Invalid Card Holder's Name" 
  94.                 Else 
  95.                     If cardType <> (creditDr("cardType")) Then 
  96.                         response_text = "Invalid Card Type" 
  97.                     Else 
  98.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate"))) 
  99.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate"))) 
  100.                         credit_limit = Trim(creditDr("creditLimit")) 
  101.                         total_credit = Trim(creditDr("totalCredit")) 
  102.  
  103.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then 
  104.                             response_text = "Invalid Credit Card" 
  105.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then 
  106.                             response_text = "Card limit is reached!" 
  107.                         Else 
  108.                             response_code = 1 
  109.                             credit_balance = Trim(creditDr("creditBalance")) 
  110.                             debit_account = Trim(creditDr("creditCardNo")) 
  111.                             credit_account = Trim(creditDr("merchantID")) 
  112.                             merchant_balance = Trim(creditDr("merchantBalance")) 
  113.                             userID = Trim(creditDr("userID")) 
  114.                             If (response_code = 1) Then 
  115.                                 If (CInt(credit_balance) = 0) Then 
  116.                                     credit_limit = CDbl(credit_limit) - CDbl(amount) 
  117.                                     credit_balance = -CDbl(amount) 
  118.                                 Else 
  119.                                     credit_balance = CDbl(credit_balance) - CDbl(amount) 
  120.                                     If (credit_balance >= 0) Then 
  121.                                         credit_limit = total_credit 
  122.                                     Else 
  123.                                         credit_limit = total_credit + credit_balance 
  124.                                     End If 
  125.                                 End If 
  126.                             End If 
  127.                         End If 
  128.  
  129.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then 
  130.                             errorInput = errorInput & "Invalid return URL path! <BR>" 
  131.                             errorExist = True 
  132.                             Response.Write("Going to redirect to user to: inputerror.aspx") 
  133.                             Response.Write("Going to redirect to user to: InvalidUrlError.aspx") 
  134.                             Response.End
  135.                         Else 
  136.                             Session("res") = response_code 
  137.                             Session("text") = response_text 
  138.                             Response.Write("Going to redirect to user to: return_url" & Request.Form("return_url"))
  139.                             Response.End
  140.                         End If 
  141.  
  142.                         If (errorExist) Then 
  143.                             response_code = 0 
  144.                             response_text = errorInput 
  145.                         End If 
  146.                     End If 
  147.                 End If 
  148.             End If 
  149.         End If 
  150.  
  151.         creditDr.Close() 
  152.         conn.Close() 
  153.     End Sub 
  154. End Class 
  155.  
CroCrew~
Newbie
 
Join Date: Oct 2009
Posts: 12
#10: Oct 15 '09

re: passing variable from asp.net to asp


this statement Request.Form("return_url")) is redirecting to payResult.asp

when I execute the code it did when to payResult.asp but it show:

<% else %>

I'm sorry,but there was a problem with this transaction.<br />
The server response was:<br />

eventhough its successfully update and insert to database...
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#11: Oct 15 '09

re: passing variable from asp.net to asp


Hello ryna,

Yes, that is because DotNet “Session” variables will not pass across to Classic ASP pages. So your If—Then statement will fall into the “else” because the condition is “False”.

Did you copy and paste my last post over your code? I need to know what the output is when you run and submit your form with it to help you.

CroCrew~
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#12: Oct 15 '09

re: passing variable from asp.net to asp


Ryna, I gave you this same answer in your other thread on the topic. Please do not double post your question because it makes it very hard for us to answer your question and it makes it hard for you to get the answer to your problem too (for example right now you probably didn't see the answer in your other thread).

Please refrain from double posting your questions in the future.

-Frinny
Newbie
 
Join Date: Oct 2009
Posts: 12
#13: Oct 15 '09

re: passing variable from asp.net to asp


Yes croCrew, I did copy and paste your code..
The output is: Going to redirect to user to: return_url payResult.asp
Newbie
 
Join Date: Oct 2009
Posts: 12
#14: Oct 15 '09

re: passing variable from asp.net to asp


to Frinavale,Noted.

=)
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#15: Oct 15 '09

re: passing variable from asp.net to asp


Hello ryna,

Try substituting both pages now with the below two pages and run your solution and tell us what you get.

icePayment.aspx
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data  
  2. Imports System.Data.SqlClient  
  3.  
  4. Partial Class icePayment  
  5.     Inherits System.Web.UI.Page  
  6.  
  7.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
  8.         Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")  
  9.         conn.Open()  
  10.  
  11.         Dim response_text As String  
  12.         Dim input(9) As Object  
  13.         Dim errorInput As String  
  14.         Dim errorExist As Boolean  
  15.         Dim inputName As Object  
  16.         Dim i As Integer  
  17.         Dim j As Integer  
  18.         Dim k As Integer  
  19.  
  20.         errorInput = ""  
  21.         errorExist = False  
  22.         inputName = New Object() {"merchant_id", "amount", "card_type", "card_num", "expireMon", "expireYr", "return_url", "ref_code", "card_name"}  
  23.  
  24.         For i = 0 To 8  
  25.             Input(i) = Request.Form(inputName(i))  
  26.         Next  
  27.  
  28.         For j = 0 To 8  
  29.             If IsNothing(Input(j)) Then  
  30.                 errorInput = errorInput & inputName(j) & " is blank.<BR>"  
  31.                 errorExist = True  
  32.             End If  
  33.         Next  
  34.  
  35.         For k = 0 To 5  
  36.             If Not (IsNumeric(Input(k))) Then  
  37.                 errorInput = errorInput & inputName(k) & " is not numeric.<BR>"  
  38.                 errorExist = True  
  39.             End If  
  40.         Next  
  41.  
  42.         Dim response_code As Integer  
  43.         Dim merchantSql As New SqlCommand("select * FROM iceMerchant  WHERE merchantID = '" & Request.Form("merchant_id") & "'", conn)  
  44.  
  45.         Dim merchant As String = Request.Form("merchant_id")  
  46.         Dim merchantDr As SqlDataReader  
  47.         merchantDr = merchantSql.ExecuteReader()  
  48.  
  49.         response_code = 0  
  50.         If merchantDr.Read() Then  
  51.             response_code = 0  
  52.             If merchant <> Trim(merchantDr("merchantID")) Then  
  53.                 response_text = "Invalid Merchant ID"  
  54.             End If  
  55.         End If  
  56.         merchantDr.Close()  
  57.         conn.Close()  
  58.  
  59.         conn.Open()  
  60.         Dim credit As String = Trim(Request.Form("card_num"))  
  61.         Dim cardName As String = Trim(Request.Form("card_name"))  
  62.         Dim cardType As String = (Request.Form("card_type"))  
  63.         Dim amount As String = Trim(Request.Form("amount"))  
  64.         Dim ref_code As String = Trim(Request.Form("ref_code"))  
  65.         Dim desc As String  
  66.         Dim time As Date  
  67.         Dim randomNo As Single  
  68.         Dim trans_date As String  
  69.         Dim trans_code As String  
  70.         Dim expireMonSql As Integer  
  71.         Dim expireYrSql As Integer  
  72.         Dim credit_limit As Object  
  73.         Dim total_credit As Object  
  74.         Dim credit_balance As Object  
  75.         Dim merchant_balance As Object  
  76.         Dim userID As Object  
  77.         Dim mBalance As Object  
  78.         Dim debit_account As Object  
  79.         Dim credit_account As Object  
  80.         Dim expireMonFM As Object = Trim(Int(Request.Form("expireMon")))  
  81.         Dim expireYrFM As Object = Trim(Int(Request.Form("expireYr")))  
  82.         Dim creditSql As New SqlCommand("select iceUser.userID, fullName, account_id, creditCardNo, cardType, expiryDate, totalcredit, creditlimit, creditBalance, iceMerchant.merchantID, iceMerchant.merchantBalance  FROM iceMerchant, iceUser INNER JOIN (  account_summary INNER JOIN iceCredit  ON account_summary.account_id = iceCredit.creditCardNo)   ON iceUser.userID  = account_summary.userID  where creditCardNo = '" & Trim(Request.Form("card_num")) & "' ", conn)  
  83.  
  84.         Dim creditDr As SqlDataReader  
  85.         creditDr = creditSql.ExecuteReader()  
  86.  
  87.         If creditDr.Read() Then  
  88.             response_code = 0  
  89.             If Not IsNumeric(credit) Or credit = "" Or credit <> creditDr("creditCardNo") Then  
  90.                 response_text = "Invalid Credit Card No"  
  91.             Else  
  92.                 If cardName = "" Or cardName <> Trim(UCase(creditDr("fullName"))) Then  
  93.                     response_text = "Invalid Card Holder's Name"  
  94.                 Else  
  95.                     If cardType <> (creditDr("cardType")) Then  
  96.                         response_text = "Invalid Card Type"  
  97.                     Else  
  98.                         expireMonSql = Month(Convert.ToDateTime(creditDr("expiryDate")))  
  99.                         expireYrSql = Year(Convert.ToDateTime(creditDr("expiryDate")))  
  100.                         credit_limit = Trim(creditDr("creditLimit"))  
  101.                         total_credit = Trim(creditDr("totalCredit"))  
  102.  
  103.                         If Not IsNumeric(expireMonFM And expireYrFM) Or (((CDbl(expireMonFM) - expireMonSql) <> 0) Or ((CDbl(expireYrFM) - expireYrSql) <> 0)) Then  
  104.                             response_text = "Invalid Credit Card"  
  105.                         ElseIf ((CDbl(amount) - CDbl(credit_limit)) > 0) Then  
  106.                             response_text = "Card limit is reached!"  
  107.                         Else  
  108.                             response_code = 1  
  109.                             credit_balance = Trim(creditDr("creditBalance"))  
  110.                             debit_account = Trim(creditDr("creditCardNo"))  
  111.                             credit_account = Trim(creditDr("merchantID"))  
  112.                             merchant_balance = Trim(creditDr("merchantBalance"))  
  113.                             userID = Trim(creditDr("userID"))  
  114.                             If (response_code = 1) Then  
  115.                                 If (CInt(credit_balance) = 0) Then  
  116.                                     credit_limit = CDbl(credit_limit) - CDbl(amount)  
  117.                                     credit_balance = -CDbl(amount)  
  118.                                 Else  
  119.                                     credit_balance = CDbl(credit_balance) - CDbl(amount)  
  120.                                     If (credit_balance >= 0) Then  
  121.                                         credit_limit = total_credit  
  122.                                     Else  
  123.                                         credit_limit = total_credit + credit_balance  
  124.                                     End If  
  125.                                 End If  
  126.                             End If  
  127.                         End If  
  128.  
  129.                         If (Left(Request.Form("return_url"), 7) <> "http://") Then  
  130.                             errorInput = errorInput & "Invalid return URL path! <BR>"  
  131.                             errorExist = True  
  132.                             Response.Write("Going to redirect to user to: inputerror.aspx")  
  133.                             Response.Write("Going to redirect to user to: InvalidUrlError.aspx")  
  134.                             Response.End 
  135.                         Else  
  136.                             Response.Redirect(Request.Form("return_url") & "?res=" & response_code & "&text=" & response_text) 
  137.                         End If  
  138.  
  139.                         If (errorExist) Then  
  140.                             response_code = 0  
  141.                             response_text = errorInput  
  142.                         End If  
  143.                     End If  
  144.                 End If  
  145.             End If  
  146.         End If  
  147.  
  148.         creditDr.Close()  
  149.         conn.Close()  
  150.     End Sub  
  151. End Class  
  152.  
payResult.asp
Expand|Select|Wrap|Line Numbers
  1. <%
  2.     If (Request.QueryString("res") = 1) Then
  3.         Response.Write("Thank You for buying GOODS from our online Store!")
  4.     Else
  5.         Response.Write("I'm sorry,but there was a problem with this transaction.<br />")
  6.         Response.Write("The server response was:<br />")
  7.         Response.Write(Request.QueryString("text") & "<br />")
  8.         Response.Write("Go back to check Out page to enter information again<br />")  
  9.     End If
  10. %>
  11.  
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#16: Oct 15 '09

re: passing variable from asp.net to asp


Sorry just made a change to "payResult.asp" Check that page again if you seen it before I made the edits.
Newbie
 
Join Date: Oct 2009
Posts: 12
#17: Oct 19 '09

re: passing variable from asp.net to asp


hi CroCrew,

it show page not found (404)...
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#18: Oct 19 '09

re: passing variable from asp.net to asp


Is "payResult.asp" in the same folder that "icePayment.aspx" is in? Are you getting a 404 when going to "payResult.asp"? Post the error that your getting.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#19: Oct 19 '09

re: passing variable from asp.net to asp


Ryna, a 404 error means that it can't find the page that you're redirecting to.

You should check to make sure that the URLs are correct.

Try using the .NET debugger (that comes with VisualStudio) to step through your code and make sure that the URLs are pointing to the right place. If you don't want to use the debugger for some reason you could try hard coding the URL of the payResult.asp page:


Expand|Select|Wrap|Line Numbers
  1. 'What are you doing here?????
  2. If (Left(Request.Form("return_url"), 7) <> "http://") Then
  3.   errorInput = errorInput & "Invalid return URL path! <BR>"
  4.   errorExist = True
  5.   Response.Redirect("inputerror.aspx")
  6. 'The following line will not be executed..................
  7. 'Anything that comes after a Response.Redirect is not executed
  8.   Response.Redirect("InvalidUrlError.aspx")
  9. Else  
  10.   Session("res") = response_code
  11.   Session("text") = response_text
  12. 'Instead of this please try hard coding the return url 
  13. '  Response.Redirect((Request.Form("return_url")))
  14. 'Try this instead 
  15. '(Make sure that the URL is correctly pointing to the payResult.asp page):
  16.   Response.Redirect("http://localhost/websiteDirectory/payResult.asp?res=" & response_code,True)
  17. End If
Newbie
 
Join Date: Oct 2009
Posts: 12
#20: Oct 20 '09

re: passing variable from asp.net to asp


hi croCrew...
my fault.The codes that you want me to test it works but

Response.Redirect(Request.Form("return_url") & "?res=" & response_code & "&text=" & response_text)
the one in bold there's curly line below...
it says variable"response_text" is used before it has been assigned a value.A null reference exception could result in at runtime.

it almost working..
Newbie
 
Join Date: Oct 2009
Posts: 12
#21: Oct 20 '09

re: passing variable from asp.net to asp


when I enter the wrong credit card it did not show the error message
which is : response_text = "Invalid Credit Card No"

however when it is successful(enter correct information) it print out this line:
Response.Write("Thank You for buying GOODS from our online Store!")
CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#22: Oct 20 '09

re: passing variable from asp.net to asp


Hello ryna,

So, is this resolved? You have your answer?

CroCrew~
Newbie
 
Join Date: Oct 2009
Posts: 12
#23: Oct 21 '09

re: passing variable from asp.net to asp


im afraid not yet croCrew..
still stuck oon receiving the response_text...
Newbie
 
Join Date: Oct 2009
Posts: 12
#24: Oct 23 '09

re: passing variable from asp.net to asp


Sir I need help in understanding this code..Any help will be appreciated :

Dim conn As New SqlConnection("data source=IFCDU2-WS23\SQLEXPRESS;initial catalog=icebank;integrated security=true")
Reply