?
Solved

How to use Webbrowser and POST

Posted on 2002-04-27
23
Medium Priority
?
160 Views
Last Modified: 2010-05-02
I have to send SQl Server login information to an ASP page that returns an HTML report to a Webbrowser control in my application. So I do it from the Webbrowser by POST, using the code below to send it, I can get the number of bytes sent using Request.ServerVariables("CONTENT_LENGTH") but when I try to get the variables using Request.QueryString("usr") or Request.Form("usr") they do not exist, could anyone help me please. Thank you and sorry for my poor english. The code is :

Public Sub OpenReport(sPath As String, sPost As String, sHeader As String)
    'Ex.
    ' sPath = url
    ' sPost = "pwd=passhere&usr=leandro"
    ' sHeader = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
    Dim bPost() As Byte
    ReDim bPost(Len(sPost))
    bPost = StrConv(sPost, vbFromUnicode)
    '
    Web.Navigate sPath, 14, vbEmpty, bPost, sHeader
    '...
End Sub
0
Comment
Question by:Leandro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
  • 4
23 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 6973124
Why don't you use the INet control (Microsoft Internet Controls - shdocvw.oca) ?

Then the code would be:

oInetControl.Execute "www.experts-exchange.com/jsp/memberLogin.jsp", "POST", "loginMemberName=" & sMemberID & _
                "&loginPassword=" & sPassword, _
                "Content-Type: application/x-www-form-urlencoded"

Where sMemberID is the member to login and sPassword is the password.

D'Mzzl!
RoverM
0
 
LVL 12

Expert Comment

by:roverm
ID: 6973125
btw:You can use the oInetControl_StateChanged event to monitor the progress since there is nothing visible when you use the INet control.
But it's way faster than the webbrowser! ;-)

D'Mzzl!
RoverM
0
 

Author Comment

by:Leandro
ID: 6973401
 Ok, but the problem is that I never used Inet Control and I noticed that it does not have a graphical interface to show the report to the user. Would I have to save a temporary document and then open it in the WebBrowser, or there is another way to do it ?

  Anyway, thank you.
0
Industry Leaders: 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 12

Expert Comment

by:roverm
ID: 6973714
Nope, first save it, then show it in the webbrowser control.
But that still would be faster.

The INet control is very well documented in the MSDN Library, but if you don't have it I could build you an example. Just say so then.

D'Mzzl!
RoverM
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6973770
hearing... how to it ends?
0
 
LVL 12

Expert Comment

by:roverm
ID: 6973816
Hi Richie, what do you mean ? "how to it ends" Mark
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6974480
I would like to know how it will ends...
I am a gentleman, you know, so i will wait until you post an answer, if you would be stooped, i could try by myself...
;)
Cheers to both!
0
 
LVL 12

Expert Comment

by:roverm
ID: 6974593
Richie:ROTFLMAOPIMP!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6975142
:O
0
 

Author Comment

by:Leandro
ID: 6977163
 The only problem with this solution is that, in some cases my app calls long running queries and I'm gonna show some response to the user. Like a progressbar or returning the document with Response.Flush.
  This calls are very mutable, so I can't preview how mutch time It will take to execute them, this eliminates the posibility of making a fake progressbar.
  So, I think that although the INet can call the page, it will be not a good solution for this specific kind of report.
  Thanks for the comments.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6977377
But the INet control "reports" progress too! In the StateChanged event you've got 12 steps. Can't you use that ?
0
 

Author Comment

by:Leandro
ID: 6977584
Yes, I know that, but this progress won't consider the real progress based on the Loop that generates the table, if the table has, for example 300 lines, the INet control has no way to know it, so it can't report the real progress, neighter I could know how many lines It will return, that's why I said that I can't fake the progressbar, it's very impredictable.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6977882
That's true, but a *real* website doesn't "know" that either. The generation of that table will be done at the server. The page doesn't send a "how big am I" signal to the browser as well.

Can't you deliver the nessacary data not via another way ?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6977951
server stores the page in somewhere before send it to you?
0
 

Author Comment

by:Leandro
ID: 6978275
 No Richie, the page is not stored anywhere, and roverm, I am not making a website, it's an application with html data reports, but also a website can show the progress with a progress bar control I've got, or I can fire Response.Flush eatch 10 or 20 lines.
  To report is made by sending the Query, the login information and other parameters to an asp page that executes the query (not pre-defined) into SQL Server, and returns a table (with no pre-defined columns, nor size), then I get the returned table properties and fill the html table, this table can have 1, 10, 100 or 500 lines depending on the requested report.
  Thanks again.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6978356
Just occured to me in your original coding:
The parameters aren't passed correctly.

Maybe just a typo here ?

You wrote:
sPost = "pwd=passhere&usr=leandro"

While it should be:
sPost = "?pwd=passhere&usr=leandro"

See the questionmark as the first character ?

D'Mzzl!
RoverM
0
 

Author Comment

by:Leandro
ID: 6978552
Thank you very mucth, it was really a mistake, but the problem is still ocurring. The variables return NULL.
0
 
LVL 12

Accepted Solution

by:
roverm earned 450 total points
ID: 6978647
If you build a simple HTML or ASP page, which submits the data to that page, will the variables then show up ?

Like:

<html>
<body>
<form action=myaction.asp method=post>
<input type=text id=usr value="USERNAME">
<input type=text id=password value="PASSWORD">
<input type=submit id=bt_submit value="Submit"
</form>
</body>
</html>

D'Mzzl!
RoverM
0
 

Author Comment

by:Leandro
ID: 6980331
No the variables didn't show up, the problem was that the Request.Form("zzz") does not return a string, so it's necessary to type (Request.Form("zzz")) to convert since there is no implicit conversion.
And about putting a "?" at the start of the POST string, it does not work, the string must be "pwd=xxx&usr=yyy".
Anyway, thank you, although you didn't give me the explicit answer, your comments helped me in finding the answers. So, I will accept your comments as answer, thank you.
0
 

Author Comment

by:Leandro
ID: 6980337
No the variables didn't show up, the problem was that the Request.Form("zzz") does not return a string,
so it's necessary to type (Request.Form("zzz")) to convert since there is no implicit conversion.
And about putting a "?" at the start of the POST string, it does not work, the string must be "pwd=xxx&usr=yyy".
Anyway, thank you, although you didn't give me the explicit answer, your comments helped me in finding
the answers. So, I will accept your comments as answer, thank you.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6980786
k, glad your problem is solved!

Thanks for the points.

D'Mzzl!
RoverM
0
 
LVL 12

Expert Comment

by:roverm
ID: 6980799
btw: You are correct, the questionmark is only nessacary if you type the url in the addressbar or do a window.navigate from script.
0
 

Author Comment

by:Leandro
ID: 6981393
You're welcome, thanks for the help...
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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