C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Aspire
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
Apple
Arbitrum
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Base Blockchain
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Docker
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
RevealBi
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Vibe Coding
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
0
Answer
Https SSL login and PDF download
Matteo Alvisi
13y
4.3k
1
Reply
Hi guys, I am writing for help for this problem: connect to the site of one of our suppliers and automatically download invoices in PDF.
I tried several ways:
1: Webbrowser -
I can get to the page with links to the pdf but I can not save them to disk (opens in new window) (PDF's are generated on the fly and are of this type https://www.axxes.fr/it/client/pge1_relevefacturepdf.aspx?selnumdoc=700051126&typ=DUP&lng=ES&famdoc=DUP&typfic=PDF)
2: Watin - I can not save automatically the pdf like Webbrowser
3: HttpWebRequest - I can not login.
This is the code I use:
string post_data = "_cm_url=/it/client/default.aspx&_cm_user=user&_cm_pwd=pwd";
string uri = "https://www.axxes.fr/it/identification/default.cgi";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri); request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
System.Net.ServicePointManager.CertificatePolicy= new MyPolicy();
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
listBox1.Text=(new StreamReader(response.GetResponseStream()).ReadToEnd());
Console.WriteLine(response.StatusCode);
}
public class MyPolicy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint,
X509Certificate certificate, WebRequest request,
int certificateProblem)
{
return true;
}
}
The supplier site is https://www.axxes.fr/it/
The authentication module is this:
<form name="blocident" action="
/it/identification/default.cgi
" method="POST"> <input type="hidden" name="_cm_url" value="/it/client/default.aspx"> <div class="e_idlign"> <div class="e_idcol1"> <label for="login" accesskey="2">Login</label> <input type="text" class="e_chp77px" name="_cm_user" id="login"> </div> <div class="nof"></div> <div class="e_idcol2"> <label for="password">Password</label> <input type="password" class="e_chp77px" name="_cm_pwd" id="password"> </div> </div> <div class="e_idlign"> <input type="image" alt="Valider l'identification" src="
/it/images/css/env/bt_ok.gif
" class="e_btOk" name="btOk"> </div> <ul id="e_identLien"> <li class="sep"><a href="
/it/pge1_clientmoralcreation.aspx
">Iscriversi</a></li> <li><a href="
/it/pge1_question.aspx
">Password dimenticata?</a></li> </ul> </form>
With Fiddler I tried to analyze the traffic of a navigation browser and this is because:
1
POST /it/identification/default.cgi HTTP/1.1
_cm_url=%2Fit%2Fclient%2Fdefault.aspx&_cm_user=u
ser&_cm_pwd=password&btOk.x=23&btOk.y=12
2
GET /it/client/default.aspx HTTP/1.1
ASP.NET_SessionId=3hbcfrzstvxwo145tpgpvmvw
IdSes=4fba1069405c428bab1........
3
GET /it/client/pge1_clientrecherche.aspx HTTP/1.1
ASP.NET_SessionId=3hbcfrzstvxwo145tpgpvmvw
IdSes=4fba1069405c428.............
While the code I posted is only a request to the CGI.
I honestly can not figure out how to access.
Seems like something is missing .. the cookie? How to manage it?
Do you have any tips?
Any idea?
Thanx again
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
initializing and accessing dictionary globally
FileShare