Getting and sending data from third party software

  • Thread starter Thread starter Beryl Small
  • Start date Start date
B

Beryl Small

Hi, I have a third party software that needs to send
information to an .aspx page for processing to communicate
with an SQL database. The software sends the information
something like this:

Mypage.aspx?Password=Mypassword

When this request hits the page, I need to pull that
variable Mypassword to use in my VB function to query the
database. I'm confused on how to get it. I tried using
Request.Form("password") and Request.QueryString
("password") but it doesn't work. I'm also going to have
to send a response back to this other software (Authorware
Macromedia). Anyone know how this should be done?
 
Request.Querystring should work. I believe it is case sensitive though. So
you need to use Request.Querystring.Item("Password")
 
Okay, I figured out how to get the value from the URL.
Request.Querystring works, but I don't know how to get the
value returned from the result of my SQL query back to
authorware. I need to be able to post the result to the
same page that executed Query. Anyone know how to do this?
 
Well that depends on a few things. You could create a form with the data and
post it to the third party, but I would look into WebRequest/Response. Here
is an example I have snipped, it may need to be changed to work. Also check
this site out.
http://west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm

Public Shared Function mgGetWebcontent(strWebSite as string, strWebPage as
string, strPostData as string, Optional intContentType as int32 = 0,
Optional httpFile as httpPostedFile = nothing) as string

Dim mgWebRequest As HttpWebRequest
Dim mgWebResponse As HttpWebResponse
Dim strText As String
Dim mgStreamReader As StreamReader

Try
mgWebRequest =CType(WebRequest.Create(strWebSite &
strWebPage),HttpWebRequest)
mgWebRequest.timeout = 90000
mgWebRequest.CookieContainer = new cookiecontainer()
dim k as int32
Dim siteUri As New Uri(strWebSite)
for k = 0 to HttpContext.Current.Request.Cookies.count - 1
'add your cookies here
dim ck as cookie = new cookie()
ck.name = HttpContext.Current.Request.Cookies(k).name
next k
mgWebRequest.UserAgent =
HttpContext.Current.Request.Headers("User-Agent")
mgWebRequest.Accept =
HttpContext.Current.Request.Headers("Accepts")

mgWebRequest.headers.add("Cookie",HttpContext.Current.Request.Headers("Cooki
e"))

if strPostData.length > 0 or not httpfile is nothing then

mgWebRequest.Method = "POST"

select case intContentType
Case = 1 'file post
' separate function snipped out will post if you need it
Case else
mgWebRequest.ContentType = "application/x-www-form-urlencoded"
mgWebRequest.ContentLength = strPostData.length 'length
Dim mgStreamWriter As new
StreamWriter(mgWebRequest.GetRequestStream())

mgStreamWriter.Write(strPostData)
mgStreamWriter.Close()
end select


else
mgWebRequest.Method = "GET"
end if
mgWebResponse = CType(mgWebRequest.GetResponse(),HttpWebResponse)

' you may not need the next part if you don't need the response cookies
and text

mgWebResponse.cookies =
mgWebrequest.CookieContainer.GetCookies(mgWebrequest.RequestUri)
mgStreamReader = New StreamReader(mgWebResponse.GetResponseStream())

strText = mgStreamReader.ReadToEnd()
dim i as int32

for i = 0 to mgWebResponse.cookies.count - 1
'add cookies to response
dim hc as httpcookie
hc = new httpcookie(mgWebResponse.cookies.item(i).name)
hc.expires = datetime.now.addyears(50)
hc.path = mgWebResponse.cookies.item(i).path
HttpContext.Current.Response.AppendCookie(hc)
next i
mgStreamReader.Close()
return strText

Catch
'catch processing snipped
end try
End function



"Beryl Small" <ber


(e-mail address removed)> wrote in message
 
Back
Top