.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Count the number of users per web page

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

Hello everyone,

I have a website that has 10 aspx pages in it, and I'm trying to count how many users are on any one page at a time, and display that number on the web page.  I have set it up to use an Application object ("TotalViewers"), and initialize it to 0 in the Application_Start event handler of the global.asax file.  My reasoning (probably way off base) is to increment the count on each page load, and then decrement the count on each page unload.  The increment part works ok, but when I add the code in the page unload event handler to decrement, it seems that Unload happens before the Page is presented to the client, so the  value always stays the same (adds one in page load, subtracts one in page unload).

How else  can I track number of users on each page?  (simply, becuase I am still a beginner).  I have already done some google searching and haven't come up with anything useful. 

All my pages are being navigated via a TreeView control.

Thank you,





View Complete Post

More Related Resource Links

Page View Count And Users Online

Hello forum I have a couple of questions.  How do I go about tracking the number page views for my web page in a sql table?  Secondly, how do I track the number of users currently online? Any help will be greatly appreciated. Thanks  

Need help redirecting users to personalized page


 Hi, first timer here so be gentle.


I've been able to create a cool little website, it's up and running with users logging in and out, I created roles so my administrative team can see sensitive data that's not available to regular and anonymous users.

Now they would like me to create a page specific to each user.  For instance when user A logs in they are redirected to a page that has information that pertains to user A only (like a list of their benefits/ their remaining vacation time). This page needs to be accessible only to user A. 

I've watched a ton of the videos but have yet to see one that covers this topic, any help would be great!!!





Want to create Page URL rewrite based on Users GUID and Display name?



I am using the asp.net membership. 

On my site I have a Profile.aspx page.

In the code behind of this page,  i get the logged in UserId (Guid) and pass

this to a method in my DAL. GetUserByUserId()


In my database I have a Table called Member which the method gets the data from

and displays details on the page about  the user.


What I want to happen is when they have logged in and are diverted to Profile.aspx,

the page URL shows www.MyWebSite/Profile/UsersName 

for example



is this possible. In my Member table I have FirstName and LastName columns or do I get the

name from the membership table.


even better would be they go straight to www.MyWebsite/JohnSmith.aspx


thank you for any help






Gridview extends past edge of div and page when editing users


I have a gridview pulling all data from one user. This gridview has an edit button and when that is clicked the gridview becomes too wide for the div/screen and I get a scroll bar. Since this gridview can only have one user in it anyway is it possible to display each field on seperate lines instead?

"Only their own" allows users to edit, then shows access denied page

I am managing a WSS 3.0 portal.  I have created custom lists where a group has contribute permissions.  Under List Settings|Advanced Settings, when I set Edit Access to "Only their own" or "None", my test users can see the Edit Icon and the Edit Item menu option, and bring up the Edit Form.  When they click "OK", they get the Access Denied page.  My experience in that past is that they should not even been shown the option to edit, and they should get Access Denied if they somehow navigate to the EditForm.aspx page.  I even tested this on a brand new site, with three Links lists, each with different Edit Access Levels (All, None, Only their own).  I added one user with contribute permissions.  He had the same result: He could get all the way to EditForm.aspx, but got "Access Denied" when he submitted his changes.  What can I do to fix this?Christopher W. Douglas

Cannot count number of checked items using jQuery

Hello,Using Microsoft built-in jquery files, when counting numbers of checked checkbox, the jquery-1.4.2.min.js cannot count the correct result ,however, the version jquery-1.3.2.min.js gives out the correct one, why?            $("#check").click(function () {                var nameSports = new Array();                var i = 0;                $('input[name=selector]:checked').each(function () {                    nameSports[i] = jQuery(this).val();                    i += 1;                });                if (loopCounter != 0) {                    alert(i);                }  

Permission Errors for Users on Home Page only of SQL Server Reporting Services Report Manager

I have spent days now investigating this problem, so any help very much appreciated! I have a remote web server 2003 running SQL Server R2 Express Edition with Reporting Services installed. I use Report Builder 3.0 locally to build report. If I login via Internet to Report Manager Web Page as an administrator I can perform all the expected and required actions, creating new folders and assigning permissions for users etc. I have added a new user "ReportUser" as a Browser of a child folder. If ReportUser longs on to home page, he receives the all too familiar error: User 'XXXXXXXX\reportuser' does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed. However, if the user starts at the child folder of home page, and then logs in, he sees the expected page, and can run the report!  This is not very satisfactory. How can I allow user to see home page, without an error message, but not be allowed to click on any folders to which he is not entitled? I am now aware that SQL Server R2 Express Edition has many limitations compared with full Editions (fixed roles, cannot manage Report Service from Management Studio etc) , and many of the "solutions" offered on the web just do not apply.   John Walton

Incorrect number of users reported in SharePoint Usage Logs

* See last post - issue appears related to KB 969231 *   It seems SharePoint 2007 usage logging with anonymous access worked in IIS6 but not IIS7. Is there a way to fix it?   Background: The SharePoint Usage logging was working fine (approximately 20,000 hits per day) until the upgrade to a new IIS7 environment. The configuration in both environments is very similar (both Anonymous Access and Windows Authentication are enabled) however the new environment is only showing 600 hits per day.   This forum response from Cornelius J. van Dyk [MVP] suggests that Usage analysis/logging with Anonymous Access doesn't work, however it does work in our old IIS6 environment (a dash "-" is just shown in the usage logs which suggests an anonymous user): http://www.eggheadcafe.com/software/aspnet/29823445/sharepoint-doubt-is-there-any-way-to-find-out-how-many-users-have-logged-in-to-the-sharepoint-site.aspx   So I've concluded it's differences in IIS6/IIS7 authentication. Reading articles on the differences (e.g.  single auth pipline instead of two-stage) doesn't highlight any obvious reasons why this wouldn't work.   Any help would be greatly appreciated.   Thanks,   Peter

Full Control users only able to edit Shared Version of page in MOSS 2007

Hi, In MOSS 2007 we have a site collection that does not allow the owners to edit pages. There is no broken inheritance in the permissions, and when a user clicks "Site Actions" and then "Edit" they get a toolbar saying they are only editing the Shared Version of the page. No pages are checked out to any other users either and the users attempting this (including the Farm account) are not able to edit these pages. What would be the next steps to debugging this problem as it is not one I have encountered previously?  

Count of number of times the document is downloaded from document library

Hi All, I am working on sharepoint 2007.  My requirement is: I need to take the count of number of times the document is downloaded from document library. I used log report which doesn't solved my purpose. Any Idea how can we acheive this ?   Regards

"Results Per Page" and "Paging Number" not retained when set by user

When a user selects the "results per page" to another number other than the default OR a user advances to a higher page number in the GridView other than page "1".  The settings are not retained when going between the "list.aspx" and "edit.aspx".  The user has to reset the "results per page" and scroll through the paging to get back to the "page number" they were at when they decided to edit the data. List --> Edit --> List Is it possible for the application to remember where the user was at after performing the operation on the edit page and return to that exact page number/location AND for it to also remember how many "results per page" the user selected?  

Forms Authentication sending user to LoginURL on first hit of page even though page has [allow users

On the first hit, and only the first hit, to my page having [ALLOW users="*"] in the web.config, the user is redirected to the LoginUrl, but on all subsequent visits to the page, the user IS allowed access.  The user shoud ALWAYS be allowed access to this page.  I suspect it is a configuration problem, so here are snippets of my web.config... <compilation debug="false" strict="true" explicit="true" /> <trace enabled="false"/> <authentication mode="Forms"> <forms protection="All" cookieless="UseCookies" requireSSL="false" slidingExpiration="false" timeout="20" name="12345678-1234-1234-1234-123456789012" loginUrl="~/Web/Login.aspx" defaultUrl="~/Web/MyPage.aspx" enableCrossAppRedirects="false" /> <authentication> <httpCookies httpOnlyCookies="true" /> <sessionState cookieless="UseCookies" />         <location path="Web/Contact.aspx"> <system.web> <authorization> <allow users="*"/> <authorization> <system.web> <location>   Can you help me figure out why users are not ALWAYS allowed access to the /Web/Contact.aspx page? Thx!      

Public URL Port Number appended for WebTaggingDialog.aspx page

Hi, I am not sure if this the right place to ask this question, We have a SarePoint site exposed to internet which has a web application at 8081 port. There server is behind a firewall which proxying 80 port network to 8081 port of SharePoint server. All Pages, Content and Images are working perfect but only the pages related to Taxonomy Store has port number appended to url which is not accepted at the firewal for example if the http://abc:8081 is my site the internet url is http://sharepoint.com all this is working but if is open page with WebTaggingControl or List with taxonomy fields the url http://sharepoint.com to going out of the browser as http://sharepoint.com:8081 so the firewall is blocking. Also I am not sure if the firewall can listen at two difference ports 80 and 8081 for a same url If this is not the right forum please redirect me to a forum where I could get help on this Thanks for taking time Deepak  

How to know the number of columns displayed on the last page for Multi column table

Hi, How will I determine how many columns to be displayed on the last page of the report if I am using a Multiple column table.  I am going to use the number of columns to multiply with the width of the body of the report. I am going to use a Function to get the product. 

Extended application: how do I specify a separate landing page for Extranet users?

This is the current scenario: http://intra - Normal internal intra. http://intra.foo.fi - Accessible through the firewall. This address extends the http://intra SharePoint application. This is the extranet. I.e. both addresses links to the same location essentially. Now our customer suddenly notified that they'd like to have a separate landing page for users arriving to the http://intra.foo.fi address (extranet users). How would you proceed in making a separate landing page? 

How to count number of characters in a textbox?

On my current form I have it validating a Canadian Postal Address (xxx xxx). The space is optional but if the user does not use a space, then once the validation passes it will insert one. How can I count the first 3 characters of the textbox, insert a space, then add the rest of the characters?Thank you

Admin page to manage users, need help with adding roles to this layout


Currently i have a page that has the following  code / layout.. as it is now, i am only displaying the roles and they cant be edited. Since this would be the admin page to manage users, what i would like is to have the Roles display as a checkbox list that shows all our roles and have the roles that the user is assigned to checked. Can that be done, if so are there any examples or tutorials i can review?


            <asp:GridView ID="GridView1" runat="server"  AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="UserName" DataSourceID="ObjectDataSource1" AllowSorting="True" Width="80%">
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                    <asp:CheckBoxField DataField="IsOnline" HeaderText="IsOnline" ReadOnly="True" SortExpression="IsOnline" />
                    <asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" ReadOnly="True" SortExpression="IsLockedOut" />
                    <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly=&quo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend