Avatar of markerasmus
markerasmus
Flag 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)
            {
                  if(!IsPostBack)
                  {
                        if(Request.Form.Count>0)
                        {
                              autoDeployment=true;
                              Session.Add("CheckUp_Database", Session["CheckUp_Database_NonTrusted"]);
                              this.IntitialisePage();
                              formMain.Visible=false;
                              Response.Write("Auto deployment triggered : ");
                              this.AutoDeployment();
                        }
                        else
                              this.IntitialisePage();
                  }
                  this.SetUserControlEvents();
            }
Programming

Avatar of undefined
Last Comment
nbkbar7

8/22/2022 - Mon
nbkbar7

This what you're looking for?
http://www.codeproject.com/useritems/Browsing_the_WEB_with_C_.asp

Also for debugging (especially at the level your looking at) you may want to look at this...
http://www.codeproject.com/internet/httpget-post.asp


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

ASKER
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.
nbkbar7

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?

Dave
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
markerasmus

ASKER
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.
nbkbar7

Are you using VS2005 or 2003?
nbkbar7

If VS2005 try going to Project -> 'project name' Properties -> Debug  and disable the Visual Studio hosting process. see what that does...
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
markerasmus

ASKER
I'm using VS2003.  There has to be a way to do this.  
ASKER CERTIFIED SOLUTION
nbkbar7

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
markerasmus

ASKER
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?
nbkbar7

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...

D
Your help has saved me hundreds of hours of internet surfing.
fblack61
markerasmus

ASKER
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.
nbkbar7

Hmmm...

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?

D
markerasmus

ASKER
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.  
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
nbkbar7

OK,

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)...

markerasmus

ASKER
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.
nbkbar7

Awesome! Hope you're able to resolver all your issues!!

Dave
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck