This project is read-only.

How to start a chat session

Topics: Developer Forum
Feb 23, 2011 at 11:35 AM

Very exiting project. It's my first look at MVC..

I've got everything installed almost withou problems. I just modyfied this function a little to fit my needs:

        public ActionResult Install(string server, string dbname, string username, string password, string adminPassword)
            var cfg = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(@"/");

            if (cfg.ConnectionStrings.ConnectionStrings["LCSK"] == null)
                ConnectionStringSettings connstring = new ConnectionStringSettings("LCSK", string.Format("Data Source={0};Network Library=DBMSSOCN;Initial Catalog={1};User ID={2};Password={3};", server, dbname, username, password), "System.Data.SqlClient");

            return RedirectToAction("InstallDatabase", new { id = adminPassword });

But now.. how do I start a new chat session. I run the MVC project. Run the OperatorConsole and enter this URL: http://localhost:52545/LiveChat/Chat/9FC8C498-6EEF-DC11-A5A3-0019B9E079FA

It's not working. I get a javascript error here:

<script type="text/javascript">
		$(document).ready(function () {
			window.setTimeout('checkMsg();', 2500);
			window.setTimeout('checkTyping();', 2500);

			$('#chatText').keyup(function (e) {
				if (e.keyCode == 13) {

			$(window).bind("beforeunload", function () {
				var close = confirm("Do you really want to close the chat session?");

				if (close) {
						type: 'POST',
						url: '/livechat/addmsg/',
						data: 'id=9fc8c498-6eef-dc11-a5a3-0019b9e079fa&msg=The visitor closed the chat session.'

				return close;
What am I doing wrong?
Feb 24, 2011 at 2:05 PM


  If you installed it via NuGet, you have to add the chat button on your page like this:

<a href="/livechat/session" target="_blank">
            <img id="lcsk_chatbutton" src="" alt="Chat button" />

And if you installed via the Source Code here, check the /Views/Home/Index.cshtml page or simply start the app you will see the chat button.

If one operator is online, the chat session will ask for name / department, if not a contact form will be displayed.

You cannot request a chat session directly without passing thru the username and department first.

Hope it's help,

Let me know if it did not do the trick.

Have a nice day!

Feb 24, 2011 at 2:08 PM

here is the chat button code sorry:

<a href="/livechat/session" target="_blank">
            <img id="lcsk_chatbutton" src="" alt="Chat button" />
        <script type="text/javascript">
            document.getElementById('lcsk_chatbutton').src = '/livechat/chatimage?r=' + document.referrer;

Mar 1, 2011 at 11:04 AM

wow.. it works!

I just added a index.htm file and pasted the chat button code.

First it didnt work. I found out that the development machine should have internet access. I gave it and it worked. Great project.

Now I'll try do implement the chat functionality to an existing website in IIS7. Do you have any info on that? I'll send you a link to the website when it's all done :)

Best Regards Tommy

Mar 1, 2011 at 1:09 PM

Hey Tommy,

  Nice to ear that ;) . You should not have any trouble deploying it the your live server, depending on your choices 1) Integrate it into an existing app or 2) creating a virtual directory only for the LCSK.

Let me know if you have trouble, I will be happy to help.