Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Restict Number of Connections......

Restict Number of Connections......

Scheduled Pinned Locked Moved Web Development
csharpasp-netsysadminwindows-adminhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    My Problem is as I have one virtual directory hosted on our server. Now I, want only 10 users can access the virtual directory at any instance of time. The server we are running is windows 2003, IIS 6, ASP.net 2.0 How can i restrict the access

    K 1 Reply Last reply
    0
    • L Lost User

      My Problem is as I have one virtual directory hosted on our server. Now I, want only 10 users can access the virtual directory at any instance of time. The server we are running is windows 2003, IIS 6, ASP.net 2.0 How can i restrict the access

      K Offline
      K Offline
      Kaushal Arora
      wrote on last edited by
      #2

      Try this

      void Application_Start(object sender, EventArgs e)

      {
      Application["ActiveSessions"] = 0;

      }

      void Session_Start(object sender, EventArgs e)

      {
      try
      {
      Application.Lock();

          int activeSessions = (int) Application\["ActiveSessions"\] + 1;
      
          int allowedSessions = 10; // retrieve the threshold here instead
      
      
          Application\["ActiveSessions"\] = activeSessions;
      
      
          if (activeSessions > allowedSessions)
      
                  System.Web.HttpContext.Current.Response.Redirect("~/UserLimitReached.aspx", false);
      
      }
      finally
      {
          Application.UnLock();
      
      }
      

      }

      void Session_End(object sender, EventArgs e)

      {
      Application.Lock();
      Application["ActiveSessions"] = (int)Application["ActiveSessions"] - 1;

      Application.UnLock();
      

      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups