473,804 Members | 3,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Httpwebrequest to HTTPS brings back the same page!!

2 New Member
Hi,

I am trying to post form values to a https web page programmaticall y
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 1929
kenobewan
4,871 Recognized Expert Specialist
Check out if the framework's default certificate policy works for you. If not, you need to implement your own:
ServicePointMan ager.Certificat ePolicy Property
Nov 15 '08 #2
wzb6
2 New Member
Check out if the framework's default certificate policy works for you. If not, you need to implement your own:
ServicePointMan ager.Certificat ePolicy Property

Hi,

CertificatePoli cy is obsoleted for this type, that is why I am using ServerCertifica teValidationCal lback. 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 Recognized Expert Expert
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
5523
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 code, status, etc...) are not returned to a separate HTML page (I am not given the option of defining a resulting HTML page to which the results are sent) - but rather I must receive them within the same page through a data stream somehow. Does...
15
4332
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 refreshing the page. I know I could write a form, submit it and go to another page. I've searched the web and I see something about HTTP Status code of 204
1
4334
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 same page testb.asp If the reference number is not blank, it will just write out what the
5
4547
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 form. Does it exist a way to do that? Thanks bjorn
6
16060
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 page with Response.Redirect("Search.Aspx", true); Sometimes the code in Page_Load within the IsPostBack part of the if statement runs and sometimes it doesn't. IN other words, sometimes IsPostBack is true and sometimes it is not!
2
3382
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 for the web site are held in a database and all the labels, buttons etc are populated at run time in the Page_Load handler. The retreval of the strings from the database is all
7
2017
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 involve exactly? I know that you use a https prefix instead of http, but that's it. Is there configuration of directories necessary? Got a good website for this basic info on https?
1
1590
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 submit of a logon web page using http? Wireless strikes me as the greatest risk. 3) Have you used http or https for Logon.aspx pages and why? 4) Anyone know if IIS on Windows Server 2003 has https built in? Easy or hard to configure?
2
3024
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 access Google Maps (not secured). The map is embedded in the page and does not open in a separate window. What solution do you recommend? Use iframes? If so, how?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.