Question

I have an ASP.NET page which usually runs quickly, but sometimes has to call an external service which can take a few seconds to respond. So, most of the time, I want this page to run as usual, synchronously, but run asynchronously when it needs to call the service.

I'm guessing I can just set <%@ Page Async="true" ... %> and only run the asynchronous code (setting the event handlers, etc) when needed, in the code-behind. If I don't set up the asynchronous event handlers, the page will run synchronously, as normal, with no performance hit or other issues.

Is that approach regarded as perfectly fine, or are there issues with that?

Was it helpful?

Solution

The approach you have laid out is fine. If the runtime detects a page marked as Async=true but which doesn't kick off any async work, it will just run the page synchronously. There is just a very small (almost immeasurable) amount of overhead.

OTHER TIPS

Try "Asp.net Ajax" Use ScriptManager , "update pannels" for the asp.net ajax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top