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

Top 5 Contributors of the Month
Post New Web Links

Get the unique session for the user

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :SharePoint


Here's my scenario, a user logs in to the sharepoint site and visits a document library, then I have this webpart that gets the username of the user and stores it in the database, however, my problem is that whenever the user refreshes the browser(press F5), another session ID is thrown to the user meaning, my code will again put the username to the database and it will now have 2 data/record in my database.

What I want to do is that whenever a user visits a document library, the username will be stored in the database once, or until he logs out or after a certain amount of time. and if the user refreshes his browser(press F5) it will not count as a view/hit therefore, the username will not be stored to the database.

I've been trying this with alot of if statements however I cant find a way to handle this. I think i really need your help again.



View Complete Post

More Related Resource Links

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

limit ASP.NET User Session without blocking production

 If the Web Site is in production and there are hits from one particular place (Say London!) and the after 1000 (or x) requests, user session should not be allowed. So what to do in such situation without affecting current production site?  Please Advice. Thanks!  

Accessing Session State in a User Control

We have a web site that implements a custom SiteMapProvider using a User Control added in the master page. I need to be able to limit the sitemap nodes added depending on the logged in user, that is, certain users should not see certain sitemap nodes. Currently, the login processing code determines if users are in the certain category or role and then sets a value in session state, for example, Session["UserInRoleXXX"] = "Yes"; I tried changing the code in the user control to check the session state, but I got the following error: NullReferenceException ... Object reference not set to an instance of an object." Can session state be accessed in a user control? If so, how? If not, any suggested solutions? Thanks in advance for any help.

how to redirect user to login page if session is null

i have 2 page,1.login.aspx ---  2.welcome.aspxin my login.aspx im storing username into sesssion as below:Session["usernm"] = txtUsername.Text;in my welcome.aspx  pagein page_load event if (Session["usernm"]==null)        {            Response.Redirect("Login.aspx");        }----- here if i manulally paste the url ( http://localhost:4125/Loginado/welcome.aspx) it should go to  login.aspx for user credentialsbut its going directly to welcome.aspx  page.

Check session timeout and warn user before timeout


I know there are several articles explaining how to warn the user before their session times out, but so far none of them have worked for our scenario, so I'm hoping someone here will be able to help me figure this one out...  Here's what we've got:

Our application uses SQLServer to store session state.  We've got it set to timeout in 60 minutes.  Unfortunately (I fought hard against this, but lost the battle) our application uses popups for several major screens.  So tracking the session timeout on the client side doesn't really work, because I have no idea what window the user is in at any given point.  I've tried the solution where you inject Javascript into the page using the current session timeout on each request, but again, because the user could be actively using the application in a different window, it doesn't work for us.  So I guess I have a couple key questions:

  1. Is there any way to get the timeout for a session without triggering a request to the server, which would just renew the session?
  2. Is there a way to track the session timeout value across multiple windows? 
    I believe there is a limit to the number of "branches" the main window can have in our app.  In other words, the user can only be 2 levels deep from the main/root window, s

User keeps losing Session on Anonymous site?


This code was working before, but something has changed and I don't know what.  I have an anonymous registration page.  On it, I have a CAPTCHA image, with a URL pointing to an ASPX page that is generating the image.  On the Registration page I am generating a 6 digit code to be displayed in the CAPTCHA image, then saving it to a Session variable.  On the CAPTCHA ASPX page, I am grabbing that Session variable and creating the image.  However, the Session is resetting when the CAPTCHA ASPX page is called.  If I debug it, it has a different ID and the variable is gone.

Why is this happening and how can I fix it?  I have Sessions enabled in SharePoint 2007.

The user does not exist or is not unique


We have just used the following link to update our object cache user accounts and after IISRESET we are now getting the above message, and are unable to access our intranet site.

We created two new AD accounts with minimal network privileges, as these would be defined within the Central Admin, as either Full Control or Full Read.

Has anyone else updated their Cache Users and did they have a similar problem, did they create new AD accounts for this or use existing ones?

Quick turn around would be nice, how can I tell what setting has been made within powershell for the portalsuperuseraccount and portalsuperreaderaccount.


How to get current user session in Windows application C#?



I am trying to create a Windows Application similar to facebook friend finder.exe in .NET. The steps I have followed to achieve this is as follows:

1. I have created a webservice containing webmethod SaveContacts(string firstname, string lastname, string number, string photo, string email, string userid).


2. I am consuming the webservice in a Windows Form application and calling the above mentioned function.

Now, I want to get the current logged in user ID which through the windows form application which is something tedious to me.

If anyone have any idea how to achieve this. Please help.






How to send and receive unique cookie to a user


Hi, I need to send a cookie to the my web site's visitors and receive them back for information. For example when machine1 visits my site if not set I set a cookie with "user1", for machine2 I set "user2" etc. 

Actually I need to retrieve the cookie back from my log file, so I thought if I do this it will be saved to my log file. Any help?

Thanks in advance

calendar - incoming email error - The user does not exist or is not unique..


I am sending calendar appointments to a sharepoint calendar.  It works fine if i send from my exchange email on the domain.  However if i try to send from outlook, which has a gmail (live account same error) account off network, the mail comes to the drop folder on my incoming email sharepoint server but then i get this error:

An error occurred while processing the incoming e-mail file C:\inetpub\mailroot\Drop\4ab7332801cb38a6000000c7.eml. The error was: The user does not exist or is not unique..

next error is

The Incoming E-Mail service has completed a batch.  The elapsed time was 00:00:00.0625004.  The service processed 1 message(s) in total.  Errors occurred processing 1 message(s): Message ID: <000001cb38a5$00a4f100$01eed300$@com>

external users can just find send email and documents to other document libraries but this calendar is giving me problems.

all servers sharepoint 2007 sp2 enterprise edition.


The user does not exist or is not unique


Hi Guys ,

  When i create a new group in sharepoint it gives me the this error

 The user does not exist or is not unique

I also cannot add add users.

I can create groups using stsadm -o creategroup .


Please help


how to maintain session for multi user application


I am developing a web application. This application is fully customised based on the user settings. Suppose, application hosted on www.abc.com and user can signup on the website and it will get the domain like www.user1.abc.com and for user2 will be www.user2.abc.com so and so forth. so in this case how would I maintain the session for each user?

each user will be representing a single website along with public interface and admin pages. 

what I am thinking is to store all the setting (for each user) in the database and then when ever server received request then get the user info from the URL (first time only and after get it from the session) and get user details but I am not very much satisfied with this approach. 

could anyone recommend me any better way to perform this task please? 


Access the user session from a web method


I want to access the user session from a web method. But when I check for the session object, its nothing! How can I access the current user's session from the webmethod?

My code:

<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
 Public Class DalService
    Inherits System.Web.Services.WebService

  <WebMethod()> _
    Public Function AddFavourite(ByVal locationId As Integer) As Integer
        Dim result As Integer = 0
        If Session IsNot Nothing Then
            'DO SOMETHING
            ReportError("SESSION IS NOTHING!!!!!!!??????", "")
        End If

        Return result
    End Function

End Class  

Storing the user's custom IPrincipal in the cache or the session?


When I first implemented forms authentication I consulted an article that told me to store the user's custom IPrincipal object in the cache.  Is this wrong?  Should I have stored it in the session?

Creating an "exclusive" session for a given user


Creating an "exclusive" session
I need to create an ASP.NET application (written in C#) in such a way that while User #1 is logged in to the application, if someone else attempts to impersonate and login as User #1 from either:
- the same machine, but using a different tab (or window) in the same browser, or .
- the same machine, but using a different browser, or .
- a different machine

Unique Session between IE7 Tabs



How can I maintain Unique Session ID between IE7 tabs. When I am trying to paste the URL in the next Tab, The page is taking the pervious session ID and the page is opened.

I need to close the session ID in the new tab and get back the page to Login page.

Please help me in fixing this problem.

Can a user's session and their security ticket expire at different times?


Hi there,

If a user's security ticket and session state are configured to expire after twenty minutes, is it possible that one could go before the other? So for example, a user could have access to a protected web page but their sessions has been lost?

Cheers, WT.

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