Link to home
Start Free TrialLog in
Avatar of markerasmus
markerasmusFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do you create a dummy post request?

I have an ASP.NET web app that handles a HTTP POST request from a separate application.  Due to IIS limitations imposed by our network security I am unable to dubug such a request.  Instead of waiting for the request, how do I create a dummy POST request for my code to manipulate?  

My Page_Load code looks like this;

private void Page_Load(object sender, System.EventArgs e)
                              Session.Add("CheckUp_Database", Session["CheckUp_Database_NonTrusted"]);
                              Response.Write("Auto deployment triggered : ");
Avatar of nbkbar7

This what you're looking for?

Also for debugging (especially at the level your looking at) you may want to look at this...

Are you able to setup IIS on the local machine for debug and trouble shooting?
Avatar of markerasmus


Thanks, this is useful to know.  Unfortunately it doesn't help me out completely with what it is I need to do.  Although this solution initiates the dummy POST request it still doesn't allow me to step through the code of the page being called.

For example below is an extract of the code that creates the dummy request.  What I need to happen is once the web request is called I need to step through the page that it is calling.  At the moment the request is all done in the background and even though the address is called I cannot use a break point on the page_load of the page being called because the work is done in the background and it doesnt' stop at the breakpoint.

HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create(address);
... (at this point I want the debug to jump to the page_load of the "address")
HttpWebResponse myHttpWebResponse= (HttpWebResponse)myRequest.GetResponse();

Any help is much appreciated.
Is the page at  address  yours?
Are you able to create a second project? One to initiate the request and the other to intercept it.

VS will allow you to debug 2 projects at a time...
Am I understanding the need correctly?

Yes, the address is mine - it's a separate project within the same solution.  I tried creating a webform within the same project and it still didn't stop at the breakpoint on the target page.  It seems to deal with the web request separately in the background.
Are you using VS2005 or 2003?
If VS2005 try going to Project -> 'project name' Properties -> Debug  and disable the Visual Studio hosting process. see what that does...
I'm using VS2003.  There has to be a way to do this.  
Avatar of nbkbar7

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm not sure I know how to do that.  If I create a separate solution and reference an .aspx page in another separate solution, how is the sollution being called going to know that it needs initiate the breakpoint?  Basically, how is this different from utilising one solution?
Open a second copy of VS2003.

Create a new project/solution in that copy. Now you can debug both solutions seperately.

The difference is that you will then be using two different windows processes to host the two web sites. Each can be controlled seperately.

Set you break points and see it that works for you...

Nope, still no joy.  I created a separate solution, and I opened the solution being called in a separate VS instance.  Then I started the HTTPREQUEST project in debug mode and set the breakpoint on the Page_Load event of the .aspx page being called in the separate instance.  Didn't stop at any break points and still dealt with the HttpWebResponse myHttpWebResponse= (HttpWebResponse)myRequest.GetResponse(); in the background.

OK let's take a step backwards.
You want to create a dummy POST so you can simulate you application being called?

Can I get more details on what you're trying to accomplish when the request comes in?

Well the scenario I have at the moment is a solution that automates a deployment process.  The app also allows for a manual deployment.  That is the purpose of the app.

A separate java application issues a HttpRequest with post data which my app then manipulates and issues an automated deployment.  Instead of relying on the java app to submit a POST every time I want to test something I have just created a test solution (HTTPREQUEST) that issue a HttpRequest with post data to simulate the java app POST.

But something is going wrong in my app.  The app knows that a request has come through but breaks somewhere down the line.  I don't know how to debug my app if a HttpRequest with POST data is initiated.  Breakpoints are just ignored and the code is processed in the background.  
if I initiate a manual deployment (i.e. don't use the web request) the breakpoints work.  =

My problem is I don't know how to tell the debugger that a external web request is about to start and to expect it.  

I hope this is clear enough.  

Look into turning on TRACE and DEBUG. Write to a logfile at various points to track the progression of your appplication.

Also just to make sure, is the application compiled in debug? If not your breakpoints won't fire (I'm sure you are but thought I'd mention it)...

I got it to work as per one of your earlier suggestions.  I tried a different a different combination of running the solution in two separate solutions with breakpoints in different places. Got it to trigger.  Many thanks.
Awesome! Hope you're able to resolver all your issues!!