Microsoft Developer Network > Samples >
ASP.NET AJAX web chat application (CSASPNETAJAXWebChat)

ASP.NET AJAX web chat application (CSASPNETAJAXWebChat)

The project illustrates how to design a simple AJAX web chat application.


Select a language
 
 
 
 
 
(23)
26,207 times
2/3/2012
E-mail Twitter del.icio.us Digg Facebook
Add To Favorites
Description
Browse Code
Q and A (6)
Sign in to Ask a Question


  • I'm confused. What's the point of this project if it isn't going to have workable and up-to-date samples?
    1 Posts | Last Post August 07, 2011
    • Three of the six questions here (including and as of this post) are about the sample not working in IE. One of the questions has not been answered since the end of May. A question answered April 24, 2011 seemed to have received an answer, but for some reason the answer wasn’t posted here and the stockoverflow link no longer exists (which is why it should have also been copied to here).
      
      Given this is the first sample I’ve tried using, I’m not impressed nor happy. I could see this if this were a VS 2008 sample, but this is supposed to be a VS 2010 sample.
      
  • Code does not work with IE9
    1 Posts | Last Post May 29, 2011
    • I was successfully able to execute the code when using chrome or firefox, but it does not work when using IE9. I tried to use the latest version of jquery and still it did not work. Please advise.
  • Datadase doubt
    2 Posts | Last Post May 10, 2011
    • Hi
      I attached the .mdf file directly to SQL server 2008 Enterprise Edition , as you described I will change the web.config accordingly. I got all four tables in the database correctly in SQL Server .
      Now
      
      "Step 4.  Create a new directory, "Data". Right-click the directory and click
              Add -> New Item -> Linq to SQL classes.(If you could not find that 
              template, please click the Data node of the tree view at the left
              hand.) In this sample, it is SessionDB.dbml. "
      This I did 
      what to do with the next step:
      
      "Step 5.  Open the SessionDB.dbml and double-click the SessionDB.mdf, you will 
              see the database in the Server Explorer. Expand the SessionDB.mdf,
              expand the Tables folder, and select the four tables, and drag them
              all to the stage of the SessionDB.dbml."
      
      How should I move forward with the codind and building the application
      
      Regards
      Shijila
      
    • Use Server Explorer to create a connection to your SQL Server 2008, this is the same way as "double-click the SessionDB.mdf".
      http://msdn.microsoft.com/en-us/library/33wwc2yw(VS.80).aspx
  • VS 2008 support
    2 Posts | Last Post May 03, 2011
    • I would like to create the whole thing in VS 2008 for , what are the changes need to be made
      
    • Try to follow the ReadMe to create this sample by Visual Studio 2008, the result will be same. If you get any problem when you reproduce the sample, please post your question here, you will get answers.
  • Database Trouble
    10 Posts | Last Post May 03, 2011
    • Hi
      When I try to do this:
      "Right-click the App_Data directory, and click Add -> New Item ->
       SQL Server DataBase. In this sample it is "SessionDB.mdf"."
      I get the following error
      "Connections to SQL Server files (*.mdf) require SQL Server 2005 Express to function properly.Please verify th einstallation of the component or download from the link [link is privided]"
      I have installed
      * Visual Studio 2008 and
      * SQL Server 2008 EnterPrise Edition 
      in my system
      
      What is the steps to correct the scenario
      
    • The mdf files are database file of Express version, so the VS need the SQL Express installed into your machine.
      Of course, we can configure the database to the SQL Server 2008. After you create the tables, you can change the connectionString,SessionDBConnectionString to yours like this in your web.config.
      
      <add name="SessionDBConnectionString" connectionString="Data Source=.;Initial Catalog=YourDatabase;Integrated Security=True;User Instance=True"
              providerName="System.Data.SqlClient" />
      
      Please use this script to generate the table schemas for SQL Server 2008:
      
      
    • --USE YourDatabase
      --GO
      
      /****** Object:  ForeignKey [FK_tblMessagePool_tblTalker]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblMessagePool_tblTalker]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblMessagePool]'))
      ALTER TABLE [dbo].[tblMessagePool] DROP CONSTRAINT [FK_tblMessagePool_tblTalker]
      GO
      /****** Object:  ForeignKey [FK_tblTalker_tblChatRoom]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblChatRoom]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker] DROP CONSTRAINT [FK_tblTalker_tblChatRoom]
      GO
      /****** Object:  ForeignKey [FK_tblTalker_tblSession]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblSession]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker] DROP CONSTRAINT [FK_tblTalker_tblSession]
      GO
      /****** Object:  Table [dbo].[tblMessagePool]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblMessagePool]') AND type in (N'U'))
      DROP TABLE [dbo].[tblMessagePool]
      GO
    • /****** Object:  Table [dbo].[tblTalker]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblTalker]') AND type in (N'U'))
      DROP TABLE [dbo].[tblTalker]
      GO
      /****** Object:  Table [dbo].[tblChatRoom]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblChatRoom]') AND type in (N'U'))
      DROP TABLE [dbo].[tblChatRoom]
      GO
      /****** Object:  Table [dbo].[tblSession]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblSession]') AND type in (N'U'))
      DROP TABLE [dbo].[tblSession]
      GO
      /****** Object:  Default [DF_tblChatRoom_NeedPassword]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_NeedPassword]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_NeedPassword]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] DROP CONSTRAINT [DF_tblChatRoom_NeedPassword]
      END
      
      
      End
      GO
      /****** Object:  Default [DF_tblChatRoom_MaxUserNumber]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_MaxUserNumber]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_MaxUserNumber]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] DROP CONSTRAINT [DF_tblChatRoom_MaxUserNumber]
      END
      
      
      End
      GO
    • /****** Object:  Default [DF_tblChatRoom_IsLock]    Script Date: 05/03/2011 09:26:28 ******/
      IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_IsLock]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_IsLock]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] DROP CONSTRAINT [DF_tblChatRoom_IsLock]
      END
      
      
      End
      GO
      /****** Object:  Table [dbo].[tblSession]    Script Date: 05/03/2011 09:26:28 ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblSession]') AND type in (N'U'))
      BEGIN
      CREATE TABLE [dbo].[tblSession](
      	[UID] [int] IDENTITY(1,1) NOT NULL,
      	[SessionID] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
      	[IP] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
      	[UserAlias] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
       CONSTRAINT [PK_tblSession] PRIMARY KEY CLUSTERED 
      (
      	[UID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
      )
      END
      GO
      IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tblSession]') AND name = N'IX_tblSession')
      CREATE UNIQUE NONCLUSTERED INDEX [IX_tblSession] ON [dbo].[tblSession] 
      (
      	[SessionID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
      GO
    • /****** Object:  Table [dbo].[tblChatRoom]    Script Date: 05/03/2011 09:26:28 ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblChatRoom]') AND type in (N'U'))
      BEGIN
      CREATE TABLE [dbo].[tblChatRoom](
      	[ChatRoomID] [uniqueidentifier] NOT NULL,
      	[ChatRoomPassword] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
      	[ChatRoomName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
      	[NeedPassword] [bit] NOT NULL,
      	[MaxUserNumber] [int] NOT NULL,
      	[IsLock] [bit] NOT NULL,
       CONSTRAINT [PK_tblChatRoom] PRIMARY KEY CLUSTERED 
      (
      	[ChatRoomID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
      )
      END
      GO
      /****** Object:  Table [dbo].[tblTalker]    Script Date: 05/03/2011 09:26:28 ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblTalker]') AND type in (N'U'))
      BEGIN
      CREATE TABLE [dbo].[tblTalker](
      	[TalkerID] [int] IDENTITY(1,1) NOT NULL,
      	[SessionID] [int] NOT NULL,
      	[ChatRoomID] [uniqueidentifier] NOT NULL,
      	[CheckInTime] [datetime] NOT NULL,
      	[CheckOutTime] [datetime] NULL,
       CONSTRAINT [PK_tblTalker] PRIMARY KEY CLUSTERED 
      (
      	[TalkerID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
      )
      END
      GO
    • /****** Object:  Table [dbo].[tblMessagePool]    Script Date: 05/03/2011 09:26:28 ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblMessagePool]') AND type in (N'U'))
      BEGIN
      CREATE TABLE [dbo].[tblMessagePool](
      	[messageID] [int] IDENTITY(1,1) NOT NULL,
      	[message] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NOT NULL,
      	[SendTime] [datetime] NOT NULL,
      	[talkerID] [int] NOT NULL,
       CONSTRAINT [PK_tblMessagePool] PRIMARY KEY CLUSTERED 
      (
      	[messageID] ASC
      )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
      )
      END
      GO
      /****** Object:  Default [DF_tblChatRoom_NeedPassword]    Script Date: 05/03/2011 09:26:28 ******/
      IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_NeedPassword]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_NeedPassword]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] ADD  CONSTRAINT [DF_tblChatRoom_NeedPassword]  DEFAULT ((0)) FOR [NeedPassword]
      END
      
      
      End
      GO
      /****** Object:  Default [DF_tblChatRoom_MaxUserNumber]    Script Date: 05/03/2011 09:26:28 ******/
      IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_MaxUserNumber]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_MaxUserNumber]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] ADD  CONSTRAINT [DF_tblChatRoom_MaxUserNumber]  DEFAULT ((3)) FOR [MaxUserNumber]
      END
      
      
      End
      GO
    • /****** Object:  Default [DF_tblChatRoom_IsLock]    Script Date: 05/03/2011 09:26:28 ******/
      IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tblChatRoom_IsLock]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblChatRoom]'))
      Begin
      IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tblChatRoom_IsLock]') AND type = 'D')
      BEGIN
      ALTER TABLE [dbo].[tblChatRoom] ADD  CONSTRAINT [DF_tblChatRoom_IsLock]  DEFAULT ((0)) FOR [IsLock]
      END
      
      
      End
      GO
      /****** Object:  ForeignKey [FK_tblMessagePool_tblTalker]    Script Date: 05/03/2011 09:26:28 ******/
      IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblMessagePool_tblTalker]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblMessagePool]'))
      ALTER TABLE [dbo].[tblMessagePool]  WITH CHECK ADD  CONSTRAINT [FK_tblMessagePool_tblTalker] FOREIGN KEY([talkerID])
      REFERENCES [dbo].[tblTalker] ([TalkerID])
      GO
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblMessagePool_tblTalker]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblMessagePool]'))
      ALTER TABLE [dbo].[tblMessagePool] CHECK CONSTRAINT [FK_tblMessagePool_tblTalker]
      GO
      /****** Object:  ForeignKey [FK_tblTalker_tblChatRoom]    Script Date: 05/03/2011 09:26:28 ******/
      IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblChatRoom]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker]  WITH CHECK ADD  CONSTRAINT [FK_tblTalker_tblChatRoom] FOREIGN KEY([ChatRoomID])
      REFERENCES [dbo].[tblChatRoom] ([ChatRoomID])
      GO
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblChatRoom]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker] CHECK CONSTRAINT [FK_tblTalker_tblChatRoom]
      GO
    • /****** Object:  ForeignKey [FK_tblTalker_tblSession]    Script Date: 05/03/2011 09:26:28 ******/
      IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblSession]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker]  WITH CHECK ADD  CONSTRAINT [FK_tblTalker_tblSession] FOREIGN KEY([SessionID])
      REFERENCES [dbo].[tblSession] ([UID])
      GO
      IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tblTalker_tblSession]') AND parent_object_id = OBJECT_ID(N'[dbo].[tblTalker]'))
      ALTER TABLE [dbo].[tblTalker] CHECK CONSTRAINT [FK_tblTalker_tblSession]
      GO
    • You can also download it from my live space:
      
      http://gpk2bg.blu.livefilestore.com/y1pWDBpXXgMYBrXuLHXrvwk95U2gg-MPZpiluZk_GRnyQVMxaVz83bXkYMv1TqGK98m5GS6ISneAj4QicIDj_ofRRDaYwhQkQx9/webchat.sql?download&psid=1
  • Scaling this sample; What portions of IIS are affected?
    2 Posts | Last Post April 25, 2011
    • I asked the following question on Stack Overflow relating to this sample:
      http://stackoverflow.com/questions/5735240/scaling 
      
      What are the correct IIS settings and .js callbacks that affect the execution of this code?
      -- Setting AsyncPostBackTimeout to a low value (5) does not cause the script to timeout or fail
      --  httpRuntime executionTimeout="5"/  in web.config does not seem to have an effect
      
      What portions of the IIS infrastructure are stressed when this application scales?
      -- What is the maximum concurrent WaitOne threads? 
      
      Please answer this question on StackOverflow so the largest possible community can see the answer:
      http://stackoverflow.com/questions/5735240/scaling 
      
    • Hello ChrisLaMont
      
      Our engineer has replied to you in the stackoverflow thread. Please check out his answer. 
      
      Thank you and have a nice day!
      All-In-One Code Framework Team