Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [VB.NET] System.Net.WebException - bad request
New Posts  All Forums:Forum Nav:

[VB.NET] System.Net.WebException - bad request

post #1 of 4
Thread Starter 
Code:
Dim webclient As New WebClient
Try
   webclient.DownloadFile("http://www.tippmix.hu/akt.php?action=print", "C:\tippmix.php")
Catch ex As WebException
   MessageBox.Show(ex.ToString)
End Try

This code worked fine for other sites I've tried, but I can't get this working. It always gives me bad request (400). Have you got any idea what should I add to the code to make it work?
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
post #2 of 4
Is tippmix.php in your root C: drive?
    
CPUMotherboardGraphicsRAM
Xeon w3680 Gigabyte X58A-UD3R GTX 295 Engineering Samples 2X Corsair XMS3 
Hard DriveHard DriveCoolingOS
Sandisk SSD Seagate Corsair H50 W7 Ult 
MonitorMonitorKeyboardCase
Viewsonic VA1912wb Viewsonic VA912b K350 CM HAF 
Mouse
Logitech M570 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Xeon w3680 Gigabyte X58A-UD3R GTX 295 Engineering Samples 2X Corsair XMS3 
Hard DriveHard DriveCoolingOS
Sandisk SSD Seagate Corsair H50 W7 Ult 
MonitorMonitorKeyboardCase
Viewsonic VA1912wb Viewsonic VA912b K350 CM HAF 
Mouse
Logitech M570 
  hide details  
Reply
post #3 of 4
Thread Starter 
No, it throws the exception and doesn't download the file. I think the server must be blocking this request, so the program can't download it.
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
post #4 of 4
Thread Starter 
I've done a bit research, and I think the problem is the lack of headers. Sadly I don't have much knowledge in this topic, so I don't know what headers should be sent when I want to download a page from that server.

Some MSDN page that will help:
WebClient Class
WebClient.Headers Property
HttpWebRequest Class
Edited by CoreXE - 3/16/11 at 6:16am
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
My PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i7 920 ASUS P6T MSI N560GTX-Ti Hawk Corsair Dominator 3x2GB 1600MHz C8 
Hard DriveOptical DriveOSMonitor
3,5 TB LG GH22NS50 Win7 64bit | Ubuntu 12.04 64bit Samsung SyncMaster 940N 
KeyboardPowerCaseMouse
Logitech K120 Corsair CMPSU-850TX Thermaltake VL80001W2Z V3 Black Edition Logitech G9 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [VB.NET] System.Net.WebException - bad request