title: Creating instances of a website dynamically
body: <p>My plan is to create a simple chat website. I'm using asp.net web pages with razor and signalR for the chat. I have the default page and chat room page done but I dont know how to "dynamically" create multiple instances of the chat room page so that /chatroom/1 is a different chatroom than /chatroom/2.
  <a href="http://i.stack.imgur.com/8yGEb.png" rel="nofollow">2 instances of chat room page</a></p>
  
  <p>I'm assuming that this could be done by making 10 chatroom pages and naming them from 1-10 but I believe thats bad practice. I've done routing already so that /room/[number] opens an instance of the chatroom page but I dont know how to make them separate from each other. If code is needed I can upload it to github. </p>
  
  <p>EDIT:
  <a href="https://github.com/ziombo/chatroom" rel="nofollow" title="Github">Github</a></p>
  
  <p>Routing:  </p>
  
  <pre><code>@using System.Web.Routing;
  @{
      RouteTable.Routes.MapWebPageRoute("{chatroom}/{number}", "~/room.cshtml", 
          constraints: new { chatroom = "room", number = "[1-9]"});
  }
  </code></pre>
  
  <hr>
  
  <p>room.cshtml</p>
  
  <pre><code>@{
      Layout = "~/_Layout.cshtml";
  
      string s = Request.Url.AbsolutePath;
      var RoomNumber = s.Substring(s.LastIndexOf("/") +1);
  }
  
  
  &lt;div id="chat"&gt;
      &lt;textarea id="chatBox" rows="40" cols="50" readonly="readonly"&gt;&lt;/textarea&gt;
      &lt;input type="text" id="message" placeholder="Your message"/&gt;
      &lt;input type="button" id="msgSend" value="Send" /&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      //simulate msgSend button with enter press when textbox focused
      $('#message').bind('keyup', function (e) {
          if (e.keyCode === 13) { // 13 is enter key
              $('#msgSend').click();
          }
  
      });
          $(function () {
              // Declare a proxy to reference the hub. 
              var chat = $.connection.chatHub;
              // Create a function that the hub can call to broadcast messages.
              chat.client.broadcastMessage = function (message) {
                  // Html encode display message. 
                  var encodedMsg = $('&lt;div /&gt;').text(message).html();
                  //get current time
                  var currentdate = new Date();
                  var datetime =
                  +currentdate.getHours() + ":"
                  + currentdate.getMinutes() + ":"
                  + currentdate.getSeconds();
                  // Add the message to the page. 
                  $('#chatBox').append('\n'+datetime+" "+encodedMsg);
              };
              // Set initial focus to message input box.  
              $('#message').focus();
              // Start the connection.
              $.connection.hub.start().done(function () {
                  $('#msgSend').click(function () {
                      // Call the Send method on the hub. 
                      chat.server.send($('#message').val());
                      // Clear text box and reset focus for next comment. 
                      $('#message').val('').focus();
                  });
              });
          });
      &lt;/script&gt;
  </code></pre>