.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

SPContext.Current.Web.CurrentUser null in application page on 2008 r2 server

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :SharePoint
With my current situation I have:
a wss3 development environment on a 2003 R2 server
then a production 2008 r2 server.

For some reason on the 2008 server the SPContext.Current.Web.CurrentUser object is null for users who are site collection administrators but may not have permission to log into the server itself; however, on the 2003 R2 server the code works fine for those users.
When googling around, I had seen something about nt permissions on the bin folder sometimes being and issue until asp.net cache picks up the dll but this is a page in the _layouts directory and the code is in the .aspx page itself. It works fine for me as a system administrator on either machine.

Any suggestions? Thanks.

View Complete Post

More Related Resource Links

SPContext.Current.Web.CurrentUser is null


I am using FBA in an internet zone of sharepoint site.

I am getting null in Current.Web.CurrentUser object even when i am logged in as FBA User. The welcome message is shown on top to ensure that FBA is working, but CurrentUser is giving null.

The same code works perfectly when logged in as Domain user in Intranet Zone.


Get current logon user id with SPContext.Current.Web.CurrentUser.LoginName

Hi all,I've been trying to search for the method to display the currently logon user id. So far, most sites I've visited used SPContext.Current.Web.CurrentUser.LoginName.I've tried this in my SharePoint custom application page. Everything works great.I have a test account, when logged in, was displayed as xxx\testacc.For some reasons, I changed the id in AD to xxx\test and did a full import to MOSS.I logged in to the custom application with the changed id, i.e. xxx\test, BUT the value of SPContext.Current.Web.CurrentUser.LoginName still displayed as xxx\testacc!How do I get the latest id? Has anyone encountered this before?Thank you.Kelvin

Connection to Exchange Server of .NET 1.1 Framework application on Windows 2008 64-bit

I am running Visual Studio 2003 .NET Framework 1.1 application on Windows 2008 64-bit machine. There is only one problem - connection to Exchange Server. The same application is running fine on Windows 7 64-bit machine (not server). I tried to use the same Interop.MAPI.dll I used for Windows 7, but it doesn't work for Windows 2008.   Please help.  

Problem with Spcontext.current.web.currentuser.name

Hi all, I am using Spcontext in code to retrive the current user login name. But some times Spcontext.current.web.currentuser.name will return name of the user who is currently logged in it is retruning user name other than the current. When I refresh the page two or three times It will return the proper user name. Can anyone help me to resolve this issue.

Deadlock issue in SQL Server 2008 R2 (.Net 2.0 Application)

The Sql Server 2008 R2 instance in question is a heavy load OLTP production server. The deadlock issue came up a few days back and is still unresolved. We received the Xml deadlock report that listed the stored procedures involved in the deadlock and some other details. I'll try to list down the facts from this xml first: Two stored procedures are involved in the deadlock, say SP1 and SP2. According to the report SP1 was running in Isolation level "Serializable" and SP2 was running in "ReadCommitted" . We have investigated the following: Are we setting IsolationLevel of SP1 to "Serializable" inside SP or in Code? - No. Is any other SP whose IsolationLevel is "Serializable" calling SP1? - No. Are the table used by SP1 called by any other SP that has Isolation Level as "Serializable"? - Yes. There are SPs that have Isolation Level set to "Serializable" and access the same tables as SP1, but we don't know whether they were running at the time of deadlock or not as the deadlock report only showed SP1 and SP2. Lines of thought: We have considered the following possible causes: Deadlock is occurring because SP1 is running as "Serializable". - Why is this SP running in Serializable when I haven't set it? Is the Isolation level escalating (like locks do)? If we figure this out and make it run as ReadCom

Application time out Error after installing SQL Server 2008 R2 64 bit + CU3


Hi all,

webapplications  are  suffering  after installing SQL Server 2008 R2 64 bit  in my mechine.

Did i have do any thjing more make the connectons(validation faster)  or SQL Server 2008 R2 behaves like that..

any idea or suggestions are appreciated.


Thanks in advacne




SPContext.Current is null in a WebService in the 12 hive layouts



  I do not understand why I cannot get the SPContext.Current instance.  It must be an IIS Setting because I get it on one machine and not on another, using identical code.

SPContext.Current is null In Custom Membership ValidateUser


Hi,I just get a problem getting SPContext.Current in Custom membership Provider.

We have successfully plugin the custom membership into Sharepoint foundation 2010. We tried to programmically update the user's full name after user logs in and it failed in 2010 version. (good in 2007)

This is the simplified code. The class is a custom membership provider.Strangely, this only happens in 2010 version and never raised a problem in 2007.

public override bool ValidateUser(string username, string password)
   bool isvalid = false;

    if(username=="admin" && password="pwd")
      isvalid = true;
     var webContext = SPContext.Current.Web; //this returns null

   catch (System.Web.Services.Protocols.SoapException exp)
    Logger.WriteLog(exp.InnerException.ToString(), "wss login error");
   return isvalid;


Please Help. Thank you.



Microsoft Excel Application in DCOMCNFG in Windows Server 2008

Microsoft Excel Application in DCOMCNFG in Windows Server 2008 is not found. This is presnt in windows server 2003. But how to configure this in Windows Server 2008.

Kindly help me as soon as possible.

The Application is performaing very slow after upgrade to SQL Server 2008 x64


Hello All,

I am writing you all after I tried a lot of solutions to resolve my Issue, please find below my issue details..

Task: Upgrade from SQL Server 2000 Ent. Edition to SQL Server 2008 X64 for IA on windows server 2008 Clustered environment (Active\Active)

SQL Server 2008 Servers HW configuration:

  • 24 GB Of Ram
  • 2x Process or dual core
  • SAN storage
  • up to 1 Tera Storage

SPContext.Current returns a null


ok, I am new to the wonder world of WSS and Sharepoint.   The objective of my code is to upload a file into a particular folder into a document library.   Well, I was able accomplish this task ( ONCE ) on a Virtual machine but something happened somewhere and the code below no longer works:


public string UploadFile(string folderName, string fileName, byte[] contents)

{            String retVal = "File : " + fileName + " Upload Successfull.";


SPContext.Current.Web.CurrentUser returns inconsistent username (With different characters)



We are using MOSS 2007 with browser enabled Infopath forms. We have a user with username "DOMAINNAME\fakgul" (Active Directory also displays the user as this). However when the user opens an Infopath form  the code line behind the form below:

SPUser openedByUser = SPContext.Current.Web.CurrentUser;

returns "DOMAINNAME\fakgül" (with "U-umlaut"). When we enter the "User information" page of that user, "Account" field also displays as "DOMAINNAME\fakgül" (with "U-umlaut").

What is more strange is this is not the consist

Use Silvelight Form as Edit page ClientContext.Current is null



I've created a custom content type and set a xap as edit form and new form.

this edit/new form of course gets open in the classic SharePoint Dialog.

the problem I have is that the ClientContext.Current is null in this context (Silverlight in Dialog)

I get a context when I host this xap in the Silverligth Web Part

what's wrong ?

properties of SPContext.Current returns null after migration



I use stsadm export to migrate my site from one machine to another. After migration, I found one of my webpart does not work. It throws a null reference exception.

I logged my webpart and found it cannot get SPContext.Current.Web and SPContext.Current.List, the both returns null and cause the exception. I removed the webpart and added it again but the exception still occured. However, I created a new List on the new site then put my webpart in and it works fine.

I think it is because my migration operattion, is there anything need attention during migration?  Why SPContext.Current cannot get properties?

SPContext.Current.Web.CurrentUser.Name returns complete value claims


Hi All, 

I just had another interesting issues in claims !

I was using this property SPContext.Current.Web.CurrentUser.Name in my webpart to show user name. 

Before it was working fine but all of a sudden it is showing complete string like this: 


before it was just showing 'name' only.

So, now i have this ugly formatted username in my welcome control !!

anyone faced the same issue? 





Server Error in '/' Application on a personalised sharepoint page



I have a login to a sharepoint subsite where the default.aspx has been modified to show a personalised page. Unfortunatley it is now showing an error relating to a datasource for a report. This has been fixed but the personalized page stillthrows an error on login so I cannot get to the settings to remove the problem.


Is it possible to remove the personalised page via the back end? Either via the sharepoint database or by Sharepoint Desiginer.


Thank you.

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