views:

58

answers:

3

Hi all! I built a web-application which calls a web-service twice in the application's log-in page - first, on Page_Load, and the second time is after a button click. When debugging, everything goes well, but after publishing the web-application and trying it - I cannot make the two calls for the web-service (each call is invoking a different function in the same web-service).

If I call it once (say, in the Page_Load) its OK, but once I get to the button click event, the page just seems to be loading but actually doing nothing (loading to infinity).

When I disabled the web-service call in Page_Load, the web-service call after the button click worked well, and if I switched between them (disabled the call in button click and enabled the call in Page_Load) the enabled one worked OK.

How come this is happening? What did I do wrong? Could it be related to the fact that the location where I published my web-application has some URL-rewriting rules?

A: 

Can you show some code segment? Have you used if (!isPostBack) in the Page_Load for calling the webservice? The Page_Load fires when the button is clicked. There might be an issue in that.

Kangkan
I'll post some code as another "answer".
Shay
A: 

If you are using WCF, make sure you close the client. I had similar behaviour before when I did not close it.

leppie
I did try service.Abort() and service.Dispose() after calling the web-service for the first time, but still it didn't help...
Shay
A: 

I don't use (!isPostBack) - I did try to put both calls after the button click event though, and still had the same problem.

Relevant parts of the code:

protected void Page_Load(object sender, EventArgs e)
{
    MyService.Functions service = new MyService.Functions();
    string str = service.DigestURL(Request.RawUrl.ToString());
    ...
}


public void submitButton_Click(object sender, ImageClickEventArgs e)
{
    MyService.Functions service = new MyService.Functions();
    string str = service.CommitLogIn(usernameText.Text, passwordText.Text);
    ...
}
Shay
@Shay: First, never put part of your question as an answer. Rather edit the question and append it at the bottom. Next, the first call is being fired at the time of button click also. Is it the right expectation? If you need the call to the first method on the service only once and not at the button click, add the condition for IsPostBack.
Kangkan