.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

Making asynchronous calls to web services during ASP.NET page processing

Posted By: DigiMortal     Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
 
Some ASP.NET web applications use web services to get some data that they display to users. Some pages may lay hardly on web services and these pages need some optimization to work better. In this posting I will show you how to use web services behind your ASP.NET page asynchronously and perform a lot of queries to web services. Sample code included! Eneta.Examples.WebAppThreading.zip VS2008 solution | 60KB Asynchronous page processing As an introduction let's see how ASP.NET supports asynchronous calls behind pages. Although we can use our own threading mechanism and avoid what is offered by ASP.NET it is more safe and time saving to use ASP.NET own infrastructure. The image on right that I stole from MSDN article Asynchronous Pages in ASP.NET 2.0 shows you how synchronous and asynchronous pages are processed by ASP.NET. I recommend to read this MSDN article because you can find also other methods for asynchronous calls. I will introduce you how to use PageAsyncTask based calls. If you look at diagram on right you can see that asynchronous processing of registered tasks happens between PreRender and PreRenderComplete events in separate threads. If we have data bound controls on our page we have to move data binding to PreRenderComplete event because this is the closest phase of page processing where asynchronous calls are finished.


View Complete Post


More Related Resource Links

.NET Delegates: Making Asynchronous Method Calls in the .NET Environment

  

One of the many great features of the .NET Framework is that it has asynchronous infrastructure built in. In .NET you can call any method asynchronously by defining a delegate for the method and calling the delegate's asynchronous methods. This is beneficial to your application because when a synchronous call is made, the calling thread is blocked until the method completes whereas an asynchronous call is made on a different thread, and this allows the original thread to continue its work while the asynchronous call is in progress.This article explains delegates in .NET and how to use them to perform asynchronous calls, eliminating age-old threading problems.

Richard Grimes

MSDN Magazine August 2001


Asynchronous Web Services, jQuery or .NET (BeginInvoke) Calls?

  

Hello,

I have been moving my application to be more AJAX-based.  Currently I have a web service call where I use jQuery to gather some textbox (string) and checkbox (boolean) results and pass it to a web service.  Everything works really well, the response time is super quick.  The only downside that I can see to this is

1) you need to use jQuery, which will add to the user's download time - this doesn't really affect my application too much because I am using jQuery throughout the site

2) users can see the code and potentially try to hack the web service because they know where it is


I am most concerned with #2.  I've been reading a lot about .NET web service calls, using IAsyncResult, http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx, and I am beginning to understand the 4 methods available in this article.  However, is there extra bloat using this way compared to the jQuery web service call?

If there isn't that much bloat or lag time using this method, I'd like to convert my application.  Which one of these 4 methods is best in a scenario where I am just returning a small string value?  The 4 methods in the article are

  • to wait for EndInvoke itself, which from what I read is not recom

Asynchronous ASP.NET Page Processing in Layered Architecture

  

I am working on an application which involves payment gateways. Payment gateway takes some 4-5 seconds to respond. To tune the application I thought of using PageAsyncTask whenever Payments are processed.

My application uses multiple layers, for e.g before hitting to payment gateway, all sorts of calculations(taxes and all) are calculated in bussiness layer and then the payment gateway processing is done in the data access layer. Method which performs the Payments  also returns some custom message to top layers based on the response value. This is done by setting a property in the DAL class.

Now issue is how to register BeginEventHandler and EndEventHandler. I tried creating a sample application for this. But when I debugged my EndEventHandler was not getting called at all.

Sample Scenario..

On a button click event I am trying to call a DAL method which will create a HttpWebRequest and will return the response to me in a string variable

My Page Class has Events below:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
            PageAsyncTask task = new PageAsyncTask(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation),new EndEventHandler(TimeoutAsyncOperation), "" );
            RegisterAsyncTask(task);

Asynchronous ASP.NET Page Processing(PageAsyncTask) in Layered Architecture

  

I am working on an application which involves payment gateways. Payment gateway takes some 4-5 seconds to respond. To tune the application I thought of using PageAsyncTask whenever Payments are processed.

My application uses multiple layers, for e.g before hitting to payment gateway, all sorts of calculations(taxes and all) are calculated in bussiness layer and then the payment gateway processing is done in the data access layer. Method which performs the Payments  also returns some custom message to top layers based on the response value. This is done by setting a property in the DAL class.

Now issue is how to register BeginEventHandler and EndEventHandler. I tried creating a sample application for this. But when I debugged my EndEventHandler was not getting called at all.

Sample Scenario..

On a button click event I am trying to call a DAL method which will create a HttpWebRequest and will return the response to me in a string variable

My Page Class has Events below:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
            PageAsyncTask task = new PageAsyncTask(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation),new EndEventHandler(TimeoutAsyncOperation), "" );
            RegisterAsyncTask(t

Reporting services in 2008 r2 how to get a report in a print button click event in my c#.net page

  

how to  get a report in my c#.net page button lick event also steps to call a report from asp.net to reporting services

 

Thanks in advance


.NET Matters: Asynchronous Stream Processing

  

This month Stephen Toub discusses asynchronous stream processing.

Stephen Toub

MSDN Magazine March 2008


Windows 2000: Asynchronous Method Calls Eliminate the Wait for COM Clients and Servers

  

Windows 2000 is the first version of COM to support asynchronous method calls, which permit clients to make nonblocking calls to COM objects and objects to process incoming calls without blocking the calling threads. COM clients benefit from asynchronous method calls because they can continue working while waiting for outbound calls to return. Objects benefit because they can queue incoming calls and service them from a thread pool. Our SieveClient and SieveServer sample apps demonstrate how to create and use asynchronous clients and servers in COM-based distributed applications.

Jeff Prosise

MSDN Magazine April 2000


Video: Coding a Long-Running Operation Page in SharePoint Server 2007 or Windows SharePoint Services

  
Watch this visual how-to video as you learn to write code to mimic the default long-running operations page (the "spinning wheel") in SharePoint Server 2007 or Windows SharePoint Services 3.0. (Length: 7:56)

Coding a Long-Running Operation Page in SharePoint Server 2007 or Windows SharePoint Services 3.0 (V

  
Watch the video and explore code as you learn how to write code to mimic the default long-running operations page (the "spinning wheel") in SharePoint Server 2007 or Windows SharePoint Services 3.0.

SQL Reporting Services - Page X of XX counts in header

  
I have searched high and low for how to calculate page numbering in the header where the global values do not apply.   I have a report that generates 300+ invoices and I need the page numbers to reflect page x of xx for that invoice only.  My report page breaks for each customer invoice.  I have found code to get the page number in the header and I have found code to get the total pages in the body.  These two solutions cannot be combined.    Has anyone found a workaround in code behind or some other method?I would appreciate any guidance.   Side note: thank you all for all your postings and solutions.  They have been highly valuable as I am new to SSRS.

Making and receiving calls using e Diva Component API

  
Programs and scripts can use the Component API in either 'blocking' or 'non-blocking' mode. The following examples use 'blocking' mode because this is the simplest. For more complex scripts and applications 'non-blocking' mode can make it easier to create programs that can cope with unforeseen sequences of events or errors.
See the section 'Handling multiple calls' for more information.

We can create the DivaCall object directly here because we are handling only one call; if we were creating more than one DivaCall object then we would have to use DivaSystem and DivaInstance and the DivaCall objects would be created using the CreateCall method of DivaInstance.

To make a call
The following code makes a call with Connect , plays the wave file with SendVoiceFile when the call is answered and Disconnects.

making page work after DB update in Form View

  
I could really use some help with this issue. I have a DropDown that allows the selection of a Category Code. The selection populates a Gridview with details of records matching the Category Code. I have only enabled the Select option on the Gridview, which when clicked populates a Formview in Edit Mode with the full record information. When editing is complete and the Update link is clicked, I can not get the page to properly reload/postback. When another Category Code is selected from the Drop Down the Gridview does not report a list of records.   Any help would be greatly appreciated.   Thanks,              

Moving part of the code/processing from Asp.net hosted in IIS to WCF-Windows Services will help to r

  
I have a web application with no user interface (GUI), this web application (asp.net) accepts some input from a program and doing some processing; In the Page Load event I am doing all processing and calling a WCF service, after receiving the response from WCF services the page get unload before writing the processing status/result to database) this asp.net application is hosted in IIS.   The WCF services is also hosted in the same machine in windows Services where IIS is hosted, I am concern about its performance of the application which is hosted in IIS.  Should I move some part of the code (processing) to another program say Create a new WCF Services and host it in Windows Services  so that the load on IIS will be reduce?  The new WCF Services will process some part of the code which IIS used to process, so helping IIS to reduce the load.       By moving some part of code from asp.net [processing] to another program hosted in WCF- Windows Services in same machine will able to reduce the load on IIS?   Please guide me.. Thanks Shaju

Permission Errors for Users on Home Page only of SQL Server Reporting Services Report Manager

  
I have spent days now investigating this problem, so any help very much appreciated! I have a remote web server 2003 running SQL Server R2 Express Edition with Reporting Services installed. I use Report Builder 3.0 locally to build report. If I login via Internet to Report Manager Web Page as an administrator I can perform all the expected and required actions, creating new folders and assigning permissions for users etc. I have added a new user "ReportUser" as a Browser of a child folder. If ReportUser longs on to home page, he receives the all too familiar error: User 'XXXXXXXX\reportuser' does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed. However, if the user starts at the child folder of home page, and then logs in, he sees the expected page, and can run the report!  This is not very satisfactory. How can I allow user to see home page, without an error message, but not be allowed to click on any folders to which he is not entitled? I am now aware that SQL Server R2 Express Edition has many limitations compared with full Editions (fixed roles, cannot manage Report Service from Management Studio etc) , and many of the "solutions" offered on the web just do not apply.   John Walton

How to hide the summary page of Web Services?

  
Hi there, a while ago I came across a way to hide the summary page of Web Services. I think it's an attribute that I can set for the entire web service interface, but I couldn't find it anymore. Does anyone know how it's done? For example, if I implemented a web service interface at using foobar.asmx, if I access foobar.asmx directly, I will see a summary page that tells me about all the webmethods available, etc. How do I prevent that page from being displayed? Thanks,- K. 

Do ASP.NET Crystal Reports support asynchronous processing

  
CR reports take too much of processing time for our web app. I have modified the process to generate reports in the background using ASP.NET asynchronus pages concept. But now, the reports do NOT render at all. This makes me wonder whether they support background processing at all.CR reports take too much of processing time for our web app. I have modified the process to generate reports in the background using ASP.NET asynchronus pages concept.But now, the reports do NOT render at all. This makes me wonder whether they support background processing at all.

How do I use Integration Services to achieve Push-mode processing for Analysis Services?

  
 [This is just for sharing information for those common asked questions collected from forums. If you have any better way or feedback, please directly reply in this thread so that community users can benefit from your answers.] Question: I have some data sources which are plain text files and I want to directly load the data from these sources to my SSAS cubes. How can I do that? Answer: Usually when you process a cube, the SSAS service will send SQL queries to the underlying data source so as to load data into the cube. This is a typical pull-mode processing. But in some cases, the data sources are non-regular databases or plain text files, which will cause difficulties to use pull-mode processing since you could not use any type of SQL. In this case, you may want to use a push-mode processing. Microsoft SSIS provides this function. It can fetch data from underlying data sources and pushes the data into SSAS cubes directly. For example, the internet order quantity of the calendar year 2001 is: 1031. But for some reason, you need to add a new record from txt file to the cube: ProductKey    OrderDateKey    DueDateKey    ShipDateKey    CustomerKey    PromotionKey    CurrencyKey    SalesTerritoryKey    SalesOrderNumber    SalesOrderLineNum
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend