+1 vote
in Other by
I'm debugging two ASP.NET applications running on the same machine under different instances of Cassini and with "custom errors" off. One app is running on port 100 and wants to perform a GET request from the other app running on port 90. So it runs this code:

WebRequest request = WebRequest.Create(

   "http://localhost:90/Controller/Action?Param1=foo&Param2=bar");

request.Timeout = 10000;

request.GetResponse();

and the last line throws a WebException with HTTP 400 code and null InnerException. If I copy the very same URL in clipboard, past it into IE running on the same machine - the request is queued to the app on port 90 and its /Controller/Action/ is invoked and even parameters are passed okay.

What could be the problem origin here and how do I solve it?

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I think you should try without the params in the url.

WebRequest request = WebRequest.Create("localhost:90/Controller/Action");

request.Timeout = 10000;

request.GetResponse();

if it does work you need to add some user-agent headers to allow the use of params.

Also you should probably look at WebClient. MSDN

personally I would also look at using IISExpress or IIS to develop this kind of solution.

Just an outsider's observation here, consider making this call to the second webmethod via an ajax call from the browser and aggregate the results clientside using javascript (jQuery).

Related questions

+1 vote
asked Jan 30, 2022 in Other by DavidAnderson
+1 vote
asked Jan 30, 2022 in Other by DavidAnderson
...