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

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

ASHX Handler KeepAlive SQL Connection?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net



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?




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

ASHX Handler + Threads

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. 

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. 

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

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

localhost is not set up to establish a connection on port 51624 with this computer


I'm trying to run asp.net locally, but getting the error

localhost is not set up to establish a connection on port 51624 with this computer

How can I fix it?

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

Unable to make connection to database?


Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.

I have database called PhoneDirectory.

It have only one table named Residents.

I have button wiht ID="Button1".

I want when i click this button to see all of my residents. 

I want to see the result in DetailsView and to be able to edin, delete and add new resident.

First try with SqlDataSource so i wrote this:

<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>" 
              SelectCommand = "SELECT * FROM Resident "

Need Oracle Data Provider .CS File for Oracle 10g Database connection !



I need a 'Wrapper.cs' file which takes care of the Database connection ( Oracle 10g) where

i can just call the method with my SQL Query


Gridview1.DataSource = SampleWrapper.ExecuteDatatable("THE SQL QUERY");


Plz Post the link if there is any open source !    

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? 

Intermittant error: "A connection attempt failed because the connected party did not properly respon



I'm having a doozy of a problem, and can't find a solution.  I have a WFC Web Service installed to a pair of servers, and accessed through a load balancer.  I am accessing the service from an ASP.NET client app, also via WCF.  The Client is not load balanced.

I'm getting an intermittant error:

(Inner Most Exception) System.Net.Sockets.SocketException:  A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond x.x.x.x:80

(Middle Exception) System.Net.WebException: Unable to connect to the remote server

(Outer Exception) System.ServiceModel.EndpointNotFoundException:  Could not connect to http://<MYSite>/<MYApp>/<MYService>.svc. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond x.x.x.x:80.

I can reproduce this error with about 20% reliability if I execute the exact same page request on the client from 2 browsers at the same time.  When the problem occurs, the successful p

Modifying connection String in Web config using Install Wizard



Im trying to create a Web Deployment Project, the built in setup and deployment is very good in Visual Studio, i need to able to add an additional step in the setup to change the connection string in the Web config file. Ive seen a lot of articles on how to do this and in particular this http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx#7162670 I am however stuck on the final part of this tutorial, im using the code Scott provided but have two errors,  heres part of my code where the errors are

using System;
using System.Configuration;
using System.Configuration.Install;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.DirectoryServices;

 void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
            // Retrieve "Friendly Site Name" from IIS for TargetSite
            DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSit

About WAP and MSSQL Connection


Is it possible to create a wap having a mssql connection?

Can you give me some sample code? thanks

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