开发者

ASP.NET: Why can't I call a web-service twice in one page?

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?


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.Te开发者_如何学运维xt, passwordText.Text);
    ...
}


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜