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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

ASHX Handler + Threads

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
Hello guys,I have a page named Calculate.ashx, the page will be called every 10 seconds until a complete result is available.I need to start 3 external applications, each to fetch information for me, the whole thing would take about 3 minutes.My question is, how do I start 3 threads and "keep in touch" with them from the ashx code, even though the context of the file will endbecause I have to send a response to client?I'm not sure I am clear so i'll try to explain it again in a different way,when a request arrives to Calculate.ashx for the 1st time, Calculate.ashx will start 3 Threads, each with it's own job.Now i need to answer the client with ResponseWrite or something, and the ashx file flow will end.In 10 seconds, the client will again send a request to Calculate.ashx, now Calculate.ashx needs to check the state of the Threads it created 10 seconds ago,Will these Threads still exist? won't they be deleted because the context ended 10 seconds ago?How do I keep the "pointers" to those Threads?Thank you!Eitam. 

View Complete Post

More Related Resource Links

ashx handler using jquery autocomplete

Hi, i have using jquery for autocompelete option and iam using ashx file , i have 2textbox  , i need to show diffrent search record in the text box, iam using 2 ashx file to show the value using jquery, i want to user single ashx file instead of iam using 2 ashx handle filercan use switch case to handle this , i want to use 7textbox  all textbox i need to do autosearch, how to handlethis senario using jquery and ashx handler file below the code this is my codebehind query clsquery.updatetablestring = "select top 2 Cont_number from ASPrearrival_list where Cont_number";         clsquery.updatetablestring = "select top 2 custid,custname from ASCustomer where custname"; // this is my auto search iam using 2 handler file , i wants only one handler instead of 2handler <script type="text/javascript" src="jquery.autocomplete.js"></script>      <script type="text/javascript">       $(document).ready(function()       {                       $("#<%=txtcontno.ClientID%>").autocomplete("Handler1.ashx");           $("#<%=txtcname.ClientID%>&q

Losing my mind, trying to publish a site with a .ashx handler


Happy Saturday everyone -


I am trying to work on a bit of a new idea to me, using .ashx files.  I understand that .ashx files need to be registered in the web.config, but I am not understanding how that works.

My .ashx file is 'album.ashx'.  My issue is that my site runs properly locally when I test it, I am just unable to publish it (locally or otherwise) - I receive the following error:

There is no build provider registered for the extension '.ashx'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.   


Inside of system.web I realize that I need to register this file, and using a template I found online this is what I have so far:




Adding a messagebox to an ASHX Handler


Is it possible to add a messagebox to an ASHX Handler? I used a handler to pass data from a Web Service to an internal system and need a messagebox to pop up to ask the user to choose from one option or another. 

ASHX Handler KeepAlive SQL Connection?




I have an ASHX Handler file, the file is connecting to an SQL server


SqlConnection con = new SqlConnection(SQL.ConnectionString()); 


I send request every 1 second to this ASHX page.

Now my question is, is it neccessery to keep the connection with the SQL alive?

Is request every 1 seconds is too much?

Any suggestions?




Problem with Web Handler - Code works as .aspx, but not .ashx


I'm trying to cover a page that is code-only to a web handler. However, I'm having problems figuring out why the code works when used in the code-behind for the .aspx file but not the .ashx page.

.ASPX Page Code Behind


Partial Class launchsite
    Inherits System.Web.UI.Page

    Protected Sub Page_Load() Handles Me.Load

        If Len(Session("UserDashboardURL")) > 0 Then
            If Len(Session("UserCurrentShowNumber")) = 0 Then
                Response.Redirect("~/development/content/dashboards/" + Session("UserDashboardURL"))
                If InStr(Session("UserDashboardURL"), "?") = 0 Then
                    Response.Redirect("~/development/content/dashboards/" + Session("UserDashboardURL") & "?ShowNumber=" & Session("UserCurrentShowNumber"))
                    Response.Redirect("~/development/content/dashboards/" + Session("UserDashboardURL"))
                End If
            End If
        End If

    End Sub

End Class



<%@ WebHandler Language="VB" Class="Handler" %>

Imports System
Imports System.Web
Imports System.Web.HttpContext
Public Class Handler : Implements IHttpHandler
    Public Sub ProcessR

This sharpoint 2010 problem solving threads

Hi friend,

you can use this thread to solving problem and solutions.

Multiple Paramatized Threads



I have a  method that calls two subsequent methods that contain multiple parameters. I would like to run these methods simultaneously and then preform an action based on the return of both methods, so The parent thread cannot continue until BOTH threads have completed. I have tried going trough MSDN examples and haven't got anything to work (the issue is that the parent thread (aka the main method) continues on once one of the thread completes). I have tried cheking the state of threads and waiting the threads, but have not gotten anywhere. Any help would be great. Thanks.

Debugging ASHX after deployment



I'm finished with a part of my ASHX handler and need to test it against the software that'll be calling it using HTTP POST. The software required an https url so I created an internally hosted site in IIS and published the project there. 

Question now is how do I do any debugging on the script to see what data is coming out of it before the data goes back into the software that's calling it? Do I set something on the project itself to be able to step into the published DLL? 

Creating Event Handler in Code behind


Hi, so I have a control that is created in the code behind and generates fine but I can't figure out how to create an event handler for it.  I've found plenty of examples for it in C sharp, but none of them seem to apply to VB.  What I want to do is essentially this:

myDropDownList.SelectedIndexChanged = "Event to do here"

but it doesn't seem to work for me.

Any suggestions are appreciated.

Pooled Threads: Improve Scalability With New Thread Pool APIs


The new threadpool APIs in Windows Vista and in the upcoming Windows Server 2008 provide advances that even native Windows developers can benefit from.

Robert Saccone

MSDN Magazine October 2007

WPF Threads: Build More Responsive Apps With The Dispatcher


Understanding the Windows Presentation Foundation threading model helps when creating user interfaces that are both compelling and responsive.

Shawn Wildermuth

MSDN Magazine October 2007

Vista and Office: View Data Your Way With Our Managed Preview Handler Framework


Stephen Toub shows you how to write your own Preview handlers for Windows Vista and Outlook 2007.

Stephen Toub

MSDN Magazine January 2007

Wicked Code: Running ASMX Web Services on STA Threads


Jeff Prosise describes performance problems in an ASMX Web service that relied on legacy COM and Visual Basic 6.0 to perform key processing tasks and the approach he took to find a fix.

Jeff Prosise

MSDN Magazine October 2006

ASP.NET Pipeline: Use Threads and Build Asynchronous Handlers in Your Server-Side Web Code


Fortunately for developers, threading in ASP.NET is a lot easier than it was in ASP. In this article, the author takes a look at threading in the ASP.NET HTTP pipeline, and explains how threads are managed efficiently without the involvement of the developer. The article considers how the common language runtime threadpool is used by ASP.NET to service requests, looks at the pooling mechanisms used for handlers, modules, and applications, and covers both IIS 5.0 and IIS 6.0 and how they differ in their approach to request processing and thread allocation. Finally, how and when to use asynchronous handlers is discussed for developers who still need to use threads in their own applications.

Fritz Onion

MSDN Magazine June 2003

Windows Forms: Give Your .NET-based Application a Fast and Responsive UI with Multiple Threads


If your application performs any non-UI processing on the thread that controls the user interface, it may make the app seem slow and sluggish, frustrating users. But writing multithreaded apps for Windows has long been restricted to C++ developers. Now with the .NET Framework, you can take advantage of multiple threads in C# to control the flow of instructions in your programs and isolate the UI thread for a fast and snappy user interface. This article shows you how. Also, it discusses the pitfalls of multiple threads and presents a framework for safe concurrent thread execution.

Ian Griffiths

MSDN Magazine February 2003

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