473,394 Members | 1,641 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,394 software developers and data experts.

WebRequest.GetResponse gives "Bad Request"

I'm using WebRequest class to access a PHP script, but keep getting a
400 error from the server when calling the GetResponse() method.

I have added the url to the script in the bypass list in machine.config
to bypass the proxy server for this request, so it should not be a
proxy issue. Also, I tried to run the same code in a Windows app, to
see if it had to do with user credentials but no luck there.
The script can be accessed with IE without any problem, so there is a
way to get to the script, I just can't get ASP.Net to do it...

This is the code:

HttpWebRequest StockRequest =
(HttpWebRequest)WebRequest.Create("http://urltomyscript/scriptname.php");
StockRequest.Timeout = 10000; //10 seconds
HttpWebResponse StockResponse =
(HttpWebResponse)StockRequest.GetResponse();

Regards,
Mange

Feb 2 '06 #1
3 3340
Are there any funny characters in your Url?

It's pretty easy to get this response from IIS
http://www.microsoft.com/"

(note the double quote at the end).

Josh
http://www.thejoyofcode.com/

Feb 2 '06 #2
also, have you tried any other URL to see if your code is working

--
Regards

John Timney
Microsoft MVP

"Josh Twist" <jo********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Are there any funny characters in your Url?

It's pretty easy to get this response from IIS
http://www.microsoft.com/"

(note the double quote at the end).

Josh
http://www.thejoyofcode.com/

Feb 2 '06 #3
Hello Mange,
I'm using WebRequest class to access a PHP script, but keep getting a
400 error from the server when calling the GetResponse() method.

I have added the url to the script in the bypass list in
machine.config
to bypass the proxy server for this request, so it should not be a
proxy issue. Also, I tried to run the same code in a Windows app, to
see if it had to do with user credentials but no luck there.
The script can be accessed with IE without any problem, so there is a
way to get to the script, I just can't get ASP.Net to do it...

[...]

Use a HTTP proxy like Fiddler to compare a working request sent by a browser
with your HttpWebRequest.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Feb 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sam Sungshik Kong | last post by:
Hello! I use Python for ASP programming. I found something weird. Response.Write(Request("something")) It draws "None" when there's no value for something. Actually I expect "" instead of...
1
by: Matt | last post by:
If we use GET protocol, we can use either Request("controlname") or Request.QueryString("controlname") to get the data entered by the user. But if we use POST protocol, we MUST use...
32
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open...
0
by: Ian Staines | last post by:
In asp the following code: Request.Servervarables("AUTH_USER") will return the header variable AUTH_USER In .NET the code Request.Servervariables("AUTH_USER") returns the server variable...
0
by: Hardy Wang | last post by:
Hi, I have an application which encrypts some certian link to format like:...
0
by: Amelyan | last post by:
I am occasionally getting this exception in production, and I can't figure out what it is. I compiled my program in debug mode, but below is the whole call stack it gives me. Doesn't tell me...
0
by: . | last post by:
http://daviderognoni.blogspot.com?locawapp - MAIN NEWS =========== * add thread * add "Request" object * new "locawapp_main" function * fixed files.py
1
by: Christian Blackburn | last post by:
Hi Gang, I'm using the following code to generate a complete URL: Session("Destination") = Request.ServerVariables("Path_Info") & "?" & Request.ServerVariables("QUERY_STRING") However that...
1
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I have written a Web Service that works with my test harness written using VS2005. However, a client to the service consistently receives a "Bad Request (Invalid Header Name)" response for each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...

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.