Web Forms :: The Client Disconnected?
Jun 27, 2010The client disconnected.File Name: {0}Method Name: {0} Application_Error Error Line Number: {0} Error Column Number: {0}
[code]...
The client disconnected.File Name: {0}Method Name: {0} Application_Error Error Line Number: {0} Error Column Number: {0}
[code]...
I implemented a chat using the COMET "way" described in this article: http://www.codeproject.com/KB/aspnet/CometAsync.aspx
In this example, the client connects for 5 seconds every time. I wanted to hold the client longer, for about 10 minutes.
My problem is - how to detect if the client disconnected during those 10 minutes? I tried using Response.IsClientConnected but it returns true even if I close the client. There must by some inidicator since the socket gets disconnected if I close the client.
I need to filter the "Client Disconnected" error below in my global.asax file. Does anyone know what kind of exception it is so that if it matches i can do extra processing?
---------------------------------------------
Message: The client disconnected.
Source: System.Web
Method: Void ThrowError(System.Exception, System.String, System.String, Boolean)
Stack Trace:at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
[code]....
disconnected mode and transaction.it's give to me ERROR message
Quote.ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized
PHP Code:
da.InsertCommand = cb.GetInsertCommand
my code is:
PHP Code:
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DBCon").ConnectionString)
Dim cmd As New SqlCommand("insert into Customer (customer_id, customer_name, note) values (@cid, @cname, @note)", con)
Dim da As New SqlDataAdapter("select * from CustomerPhone", con)
| [code]....
First, let me explain a little bit about my setup. My server is setup as a Marshaled singleton object:
RemotingServices.Marshal(lsServer, ServerObject.objectUri);
In order to have two-way communication from the server to the client, the client activates a ServerObject, then passes in its own ClientObject (which is also a MarshalByRefObject) the server uses the ClientObject to talk back to the client:
var lsClient = new ClientObject();
var lsServer = (ServerObject)Activator.GetObject(typeof(ServerObject), url);
lsServer.attach(lsClient);
When the attach method is called, the server takes the ClientObject and stores it in a List:
public void attach(ClientObject client) {
clientList.Add(client);
}
The server can then call a method on the ClientObject called "SendMessage" to communicate to each client in its list:
foreach(var c in clientList) {
c.SendMessage("Hello");
}
This works great until a client is encountered that has disconnected. In this case, an error is thrown about the client refusing the connection. I can catch the error, but the problem is I cannot remove the reference to the ClientObject from the server's List. The following re-throws the "connection refused" exception anytime a client has been disconnected:
clientList.Remove(badClient);
So a couple of questions:
1- Is there a way to detect the connection state of a client without having to catch an error?
2- When I do detect a client that has disconnected, why does the attempt to remove the object from the server's list appear to "communicate" with the client (thus causing the exception to be thrown again?)
EDIT
As Patrick pointed out below, doing a Remove from a list causes the List to iterate my objects and do a comparison on them (calling .Equals) - this is what caused my ClientObject to attempt to communicate again and thus throw the exception. To resolve it, I instead changed the List to a dictionary keyed off a unique ID supplied by my Client at the time of attaching to the server. Then I used that unique ID to remove the client. I never did find a direct way for determining if a client had disconnected other than catching the error.
The DataSet is a disconnected data object. Once the DataSet has been filled, the connection can be closed and the DataSet's contents can still be examined and manipulated.What does manipulated mean ? If possible, then please give me example(s) for manipulated.
View 5 RepliesI have designed program to display live events/content(like online orders in shop) at different location. Now case is, suppose Some of Clients putting order for material and suddenly Internet gets disconnect.So what I am looking for, in this case, I want to show some default text/images to End user who is trying to put orders. I am ready to design to Desktop Application to do this, but I need inputs on how to achieve this at User end?
View 5 RepliesI have a question, much liket this unanswered one. I'm trying to work with the entity framework, and having a tough time getting my foreign tables to update. I have something basically like this in the DB:
Incident (table):
-ID
-other fields
Responses (table):
-FK:Incident.ID
-other fields
And and entities that match:
Incident (entity)
-ID
-Other fields
-Responses (EntityCollection of Responses via navigation property)
Each Incident can have 0 or more responses.
In my Webpage, I have a form to allow the user to enter all the details of an Incident, including a list of responses. I can add everything to the database when a new Incident is created, however I'm having difficulty with editing the Incident.
When the page loads for edit, I populate the form and then store the responses in the viewstate. When the user changes the list of responses (adds one, deletes one or edits one). I store this back into the viewstate. Then when the user clicks the save button, I'd like to save the changes to the Incident and the Responses back to the DB. I cannot figure out how to get the responses from the detached viewstate into the Incident object so that they can be updated together.
Currently when the user clicks save, I'm getting the Incident to edit from the db, making changes to the Incident's fields and then saving it back to the DB. However I can't figure out how to have the detached list of responses from the viewstate attach to the Incident. I have tried the following without success:
Clearning the Incident.Responses collection and adding the ones from the viewstate back in:
Incident.Responses.Clear()
for each objResponse in Viewstate("Responses")
Incident.Responses.add(objResponse)
next
Creating an EntityCollection from my list and then assiging that to the Incident.Responses
Incident.Responses = EntityCollectionFromViewstateList
Iterating through the responses in Incident.Response and assigning the corresponding object from viewstate:
for each ObjResponse in Incident.Responses
objResponse = objCorrespondingModifedResonseFromViewState
Next
These all fail, I'd like to be able to merge the changes into the Inicdent object so that when the BLL calls SaveChanges on the changes to both the Incident and Responses will happen at the same time.
What is Web services? What is Web services? How can I Transfer the data from server to client and client to server using XML. Need one simple Example program(C# web Application) ...
View 1 RepliesIf I have something like the following:
<asp:TextBox id="test" runat="sever"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="test"
ErrorMessage="Required"></asp:RequiredFieldValidator>
<asp:Label runat="server" id="lblStatus"></asp:Label>
if in the code behind, I set the label to "You must enter a value if the textbox is empty" to validate it on the server side and this is fine, but if javascript is enabled, I don't want to show the client side validation and the server side label together. Is this something where I would just have to disable the client-side validators if javascript was enabled?
We've got a client app which connects using TCP to a server. Additionally, the client app makes use of .NET remoting to talk to another piece of locally running code.
I'm tasked with creating a "Client Simulator" to do some testing, where we'd need to have 100's of clients connected simultaneously to the server. Ideally, this would work out great if I were to run each client in it's own space, such as a VM, but this is not logistically feasible.
how to handle this? Is there a tool that could do something like this? Or some sort-of .NET concept I could use?
I have a user control which contains a CustomValidator which is used according to whether a RadioButton is checked or not (there are several RadioButtons, I'm only showing the relevant one)
<asp:RadioButton runat="Server" ID="RadioBetween" GroupName="DateGroup" CssClass="date_group_options_control_radio" />
[code]...
There is some client + server side validation code (the server side code does exactly the same thing and is skipped for brevity)
<script type="text/javascript">
function ValidateDateFields_Client(source, args) [code]...
There are two instances of this control in the page. When running the client side version it hits the wrong one (the version of the control which is disabled). You can see from the generated HTML both are correctly specified. I'm not sure how .NET works out which clientside function to call given they both have the same name.
<script type="text/javascript">
//<![CDATA[
var ctl00_MCPH1_QueryTextValidator = document.all ? document.all["ctl00_MCPH1_QueryTextValidator"] : document.getElementById("ctl00_MCPH1_QueryTextValidator");
[code]...
Do i need to add something in to scope it? What's the best way to achieve this? If I disable the loading of the second control everything works fine.
I am working with a chatServer application. I want to transfer(share) one file from client machine to another client machine, like gtalk file send without saving that file in server (I meen directly transfer from client to client). How can i do this in asp.net
View 7 RepliesI'm going to create my own project, and i have some difficulties with technology selection. I will have client application(windows forms) and web service. Data exchange between clients will be only by using this web service. Data will be like image stream,so I don't know which technology to use. I started to look at WCF, but i don't know a lot about it.
View 3 Repliesi am using a image inside a accordion header. The client id of the image is changing everytime the page gets loaded or refreshed. I am using a master page. I am using a update panel in the page. How to keep the client id of the image unchange every time when the page gets loaded.
View 1 RepliesI am building a web application that needs to be able to interact with a desktop application. Essentially, what I need to be able to do is to execute an .EXE file with command line arguments on the client from the web application when a form submits. My initial thought is to develop an ActiveX control to handle this, but I have never done this before.
View 6 Repliesi need to get a client IP Address, which is connect in the LAN, i tried multiple method,
1)Request.UserHostAddress
2)Request.ServerVariables("REMOTE_ADDR")
3) Dim strHostName As String = System.Net.Dns.GetHostName()
Dim clientIPAddress As String = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString()
Response.Write("
.clientIPAddress--" & clientIPAddress)
4)Dim ipHost As IPHostEntry
ipHost = Dns.GetHostEntry(Dns.GetHostName())
Response.Write(ipHost.AddressList(0))
im getting only the server IP address means where the application is hosted, i need Client IP Address which is available in msconfig, like IPAddress, Subnet Mask....
I want to send an sms from my web form to the client ....
View 1 RepliesHow to get information of client pc behind router using c# in asp.net
View 5 RepliesFor some project requirement I need to have a list of all client ids generated against server controls on an ASP.NET page in a dropdown..Any Idea how to move forward..??
View 2 Repliesusing System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class ResponseTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var a = Request; //I didn't find the data in Request's structure.
Response.Write("successed; hello World;");
}
}
//-----------------------javascript--------------
for( var i=0; i<this.dataToBeSent.length && this.dataToBeSent[i].hasSent == false; i++ )
{
xmlRequest.open("POST",this.dataToBeSent[i].url,true);
xmlRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlRequest.setRequestHeader("Content-length", this.dataToBeSent[i].data.length);
xmlRequest.setRequestHeader("Connection", "close");
xmlRequest.onreadystatechange = function()
{
var j = j || i;
if(xmlRequest.readyState == 4 && xmlRequest.status == 200)
{
if( xmlRequest.responseText.toLowerCase().indexOf("successed") > -1 )
{
this.dataToBeSent[i].hasSent = true;
}
}
};
xmlRequest.send(this.dataToBeSent[i].data); // xml data
}
I want to develope ranking service in my website in which every user (not registred users) can increase/decrease a subject rank through the page. Due to anonymous users can change rankings, I desire to achieve client MAC address in order to perevent some malicious activities and deliberately invalid increment/decrements.
View 5 Repliesi have a web form on my website where i want to have the mac address of client side in asp.net. Can anyone tell me is it possible or not? If yes then how can we have it.
View 5 RepliesWhat is autopostback? Please explain me with a small example with client/Server.
View 8 RepliesI have (probably for you) a strange question. How can a server receive a url from a script and not return a webpage. The server should only process some data of the params in the url.So, the clientmachine, which runs the script, doesnot notice anything at all from the server. On the serverside it is like using only a module and not webpages for processing some logic.Can someone give me hand how to program that on the server (W 2003)?
View 3 Replies