473,441 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Httpwebrequest to HTTPS brings back the same page!!

2
Hi,

I am trying to post form values to a https web page programmatically
using Httpwebrequest but no matter what I do the same login page is
returned instead of the next page. I would very much appreciate if
someone could show me what is it that I am doing wrong. Below is the
code that I am using.

Expand|Select|Wrap|Line Numbers
  1. Imports System.IO 
  2. Imports System.Net 
  3. Imports System.Net.Security 
  4. Imports System.Security.Cryptography.X509Certificates 
  5.  
  6. Public Class Form1 
  7.  
  8.     Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean 
  9.         If certificate.Issuer.Contains("OU=Diadora") Then 
  10.             Return True 
  11.         Else 
  12.             Return False 
  13.         End If 
  14.     End Function 
  15.  
  16.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
  17.  
  18.         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate) 
  19.  
  20.         Dim Req As HttpWebRequest 
  21.         'Dim SourceStream As System.IO.Stream 
  22.         Dim Response As HttpWebResponse 
  23.  
  24.         '-- get file 
  25.         Dim URL2 As String = "https://mysite.com:8443/filelist/library.htm?o_id=2" 
  26.         Req = HttpWebRequest.Create(URL2) 
  27.         Req.Credentials = New NetworkCredential("admin", "password") 
  28.         Req.AllowAutoRedirect = False 
  29.         Response = Req.GetResponse() 
  30.         Dim sr2 As IO.StreamReader = New IO.StreamReader(Req.GetResponse.GetResponseStream) 
  31.         '-- check responser, and make sure you are logged in 
  32.         Dim html_data As String = sr2.ReadToEnd 
  33.         Console.WriteLine(sr2.ReadToEnd) 
  34.         Response.Close() 
  35.  
  36.     End Sub 
  37.  
  38.  
  39.  
  40. End Class 
Nov 14 '08 #1
3 1904
kenobewan
4,871 Expert 4TB
Check out if the framework's default certificate policy works for you. If not, you need to implement your own:
ServicePointManager.CertificatePolicy Property
Nov 15 '08 #2
wzb6
2
Check out if the framework's default certificate policy works for you. If not, you need to implement your own:
ServicePointManager.CertificatePolicy Property

Hi,

CertificatePolicy is obsoleted for this type, that is why I am using ServerCertificateValidationCallback. But SSL acceptance is not my issue, I am already bypassing this. My problem is that no matter what I do, I never get passed the Log In page.
Nov 16 '08 #3
Plater
7,872 Expert 4TB
Have you used a packet watcher to make sure the data you submit via HttpWebRequest is the same as the data you submit via a regular client browser? All cookies, and session header objects in place?

Also, do you not still need to set the HttpWebRequest object to use https? I am pretty sure it ignores it if you don't
Nov 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Terence Parker | last post by:
I am trying to connect an e-commerce system to a payment gateway (located in Hong Kong). The gateway takes values in the form of a simple form submit - however, the results (i.e. authorisation...
15
by: wk6pack | last post by:
Hi, I have a problem and not quite how to go about solving it. I have a form written in asp. I wish to submit the form and have the server return back to the same page without actually...
1
by: Hugo Botha | last post by:
Hi, I have created 2 asp pages called testa.asp and testb.asp testa.asp has a link to go to next page testb.asp testb.asp has a form that ask you for a reference number and post it to the...
5
by: Bjorn | last post by:
Hi, I need to submit in the same page two forms to two different ASP-pages. I created two forms, each with hidden input and a submit button. But it doesn't work. Nothing happens with the second...
6
by: DotNetGruven | last post by:
I've got a page that does a search... There is an ImageButton on it that allows the user to reset the search. The Click Handler for the button clears out the Data and then redirects to the same...
2
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings...
7
by: Stimp | last post by:
I have a login page on a Windows IIS server: login.aspx I'd like to enable the user to optionally use HTTPS to login so that their password would not be easily snooped out. What does this...
1
by: Randall Parker | last post by:
1) What sorts of scenarios make the possibility of sniffing out a password a higher risk? 2) Do packets travel unencrypted over 802.11 wireless? Is it easy to sniff such packets and catch a...
2
by: Daniel Frechette | last post by:
Hi, Is it possible to have secured (SSL/HTTPS) and non-secured (HTTP) content in the same page without breaking the security? I am developing a secured reservation system in which the user can...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.