Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [spcontext]

Represents the context of an HTTP request in Microsoft SharePoint Foundation.

1
vote
2answers
46 views

How do I create a second context?

How do I create a second context pointing to another sitecollection (still same domain) by using the logged in user's credentials in SharePointOnline with CSOM C#? I don't want to login a second time. ...
0
votes
1answer
30 views

Sp list item access via c# - clarification

This may be a stupid question but I'm trying to understand what this line of code does. I get that it accesses a list item - but for what List? SPContext.Current.ListItem.Properties["TwitterUsernames"...
0
votes
2answers
222 views

SPContext.Current is null while calling SPContext.Current.Web.EnsureUser() method

SPContext.Current is null while calling SPContext.Current.Web.EnsureUser() method. Any suggestions?
0
votes
1answer
287 views

Get SPContext in Web Method of Provider hosted app of MVC Forms

I am developing a Provider hosted app of MVC type for SharePoint Online. I am trying to get the SharePoint Context in a Web Method in provider Hosted app of Type MVC application. I am able to get ...
3
votes
1answer
6k views

SPFx - How to get current user properties with PnP-JS-Core [duplicate]

I want to get current user login name with PnP-Core-Library for SPFx in Office365. My page is modern Page аnd I can not use it _spContextPageInfo How to do this?
1
vote
0answers
70 views

Context problem, SPAppToken is null after redirect

I have a provider hosted (MVC/C#/CSOM) addin. In this addin I have a homecontroller with an index-page. The page(Page A) has links to another page on the same web application (VS project) ("Page B"). ...
0
votes
1answer
402 views

Hot to get list's title in current language?

Can anyone help me with getting data from sharepoint in foreign language ? Imagine, that I've alredy successfully loaded list by title like this: //listTitle = "Contacten" in Dutch var SpList = ...
1
vote
1answer
334 views

Online, C#, CSOM and ClientContext : how to get password from ClaimAuth?

I really need your help on this. I would like to know how i can retrieve current user's password and login from a ClaimClientContext.GetAuthenticatedContext. What i want : I'm trying to code a ...
2
votes
0answers
662 views

SharePointContextProvider.Current.GetSharePointContext(Context) returns null on postback from IE browser from provider hosted app

I have a provider hosted app hosted on Azure and installed in SharePoint Online (Office 365). It works fine on Google Chrome browser but fails to get SharePoint context on post back using ...
1
vote
1answer
207 views

How to get list items from another site collection in remote event receivers

I have created a remote event receiver which is working fine. Now there is change in functionality such that, we have to bring some items from another site collection with in same web application, in ...
0
votes
0answers
174 views

What does SPContext.Current.Web.CurrentUser.ID returns?

Could anybody kindly let know what does SPContext.Current.Web.CurrentUser.ID returms. Is it the same ID which Active Directory uses to store ID of user. Thanks
3
votes
1answer
361 views

What is the best practice to get the context of subsite?

I have created a provider hosted app with adfs. In this app I have the SP clientContext of the site collection. I have a form in this app. When the user submits the form, there will be created a ...
1
vote
2answers
270 views

How to get SPContext in my custom class in my app

I created an provider hosted app in vs. In the app I have a mvc web project. In the controller I have the SPContext and can do SP logic. I created some helper class. In this helper class I would also ...
2
votes
1answer
40 views

Importance of .Include in the query

Following this msdn page on SharePoint development I have encountered the following issue that I do not understand. Case scenario: We are trying to retrieve List of all visible Lists that are present ...
3
votes
2answers
963 views

Problem with RunWithElevatedPrivileges and Context

I'm trying to modify two properties I have in several documents in my SharePoint library. This is the code I use to get into the library: public SPArchiveBDI(string sharepointsite, string ...
3
votes
2answers
137 views

Can't find the site url

I am developing a sharepoint app (add-in) but I'm pretty new to sharepoint over all and need some help. Asume that I am hosting the app on app-(app_id).sharepointapp.com and from that app I want to ...
2
votes
3answers
19k views

Use Current User's Credentials for SharePoint Online C#

I am currently using my account's credentials to run some custom code in my SharePoint Online provider-hosted Add-in. I am passing the credentials this way: SecureString passWord = new SecureString()...
1
vote
0answers
30 views

Example DataService (with EF) in SP2013

Does anyone have a good example how to create a (WCF) dataservice in SharePoint 2013, WITH the use of Entity Framework? I need to be able to retrieve the SPContext also, so I guess this will be a ...
2
votes
1answer
752 views

SPContext.Current is null in application page

I created a simple SharePoint solution and added one application page, in code behind I am not able to access SPContext.Current because it is returning null see below code using System; using ...
0
votes
1answer
59 views

Redirect in UserControl

I have an issue to redirect page on the page load of my user control For this i use string sRedirectionURL = "/mylist/forms/allitems.aspx"; SPUtility.Redirect(sRedirectionURL + Request.Url.Query, ...
2
votes
0answers
682 views

Update SP Item in Parallel.ForEach loop

I'm trying to update columns of a ListItem in sharepoint using the following code: ClientContext context = CreateClientContext(_siteUrl); SP.List list = GetList(listName, context); Uri baseUri = ...
4
votes
1answer
3k views

Sharepoint 2013 with custom webapi service

I want to add a custom webapi service to sharepoint 2013. What I did so far is Create the webapi application Added an application in IIS Imported the webapi application Tests are succesfull to get ...
1
vote
0answers
354 views

FormContext.FormMode == DISPLAY after calling Edit Item in custom list

In a custom webpart we check on PageLoad the SPContext.Current.FormContext.FormMode to show different additional controls on edit and display mode. If the list is created manually everything works ...
5
votes
1answer
705 views

Missing properties of _spPageContextInfo after page load

I have a script that provision site collections under a specific managed path. In these site collections, I have sub webs with page libraries in which I have several different pages with custom ...
1
vote
1answer
218 views

SPContext.Current.Web.CurrentUser returns wrong user (Broken user database?)

This code snippet is used to Break Role Inheritance on a Document Library and set the current user as the only user who has "Read" priviliges on that Library: SPUser oUser = SPContext....
3
votes
1answer
566 views

Start workflow using App only client context

I use CSOM with client contex which I get from app, the App has following permissions: <AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/...
0
votes
1answer
207 views

Why is IsCurrentUserMemberOfGroup throwing an exception when run on SPSite.RootWeb?

Running this code in PowerShell (or even in a web context in C#) gives an unexpected behavior: Calling IsCurrentUserMemberOfGroup directly on the RootWeb object gives an exception, and worse: it ...
2
votes
1answer
438 views

Create context for another site collection using NAPA

I am trying to access another site collection using NAPA. I found 2 ways, none of which seem to be working Office 365- Accessing lists refers wrong URL (URL/App name) var context = new SP....
1
vote
0answers
333 views

SPContext.Current is null

I am making a call to a Web service on the initial load of the page through an Angular JS Service. The Web service calls a DLL where I am accessing SPContext.Current. If I am allowing the application ...
0
votes
0answers
5k views

SP2013 - The object is used in the context different from the one associated with the object

I have a function that initializes a custom taxonomy control, as below (not in myControl.js) function initMyControl() { if (something is true) { var context = new SP.ClientContext(...
2
votes
1answer
2k views

clientContext is always null in Provider Hosted App

I am following this article- http://chakkaradeep.com/index.php/building-apps-for-sharepoint-with-mvc/ to learn building Provider Hosted Apps in SharePoint. I have one developer site collection (I am ...
0
votes
0answers
25 views

Give site directly using client context

I have many sites in my site collection, and I am wanting to get the pages of one site. Is there anyway to give the site that you want the pages for? so like clientcontect.get_site('sitename')
0
votes
1answer
489 views

Get the title and/or link of the parent website in javascript in SP2013

Is it possible somehow in JavaScript to acquire the title and/or link of the parent of my current site? I know that I can create a client context with a specific URL, but is it possible to do this ...
2
votes
1answer
1k views

What is difference between httpcontext and spcontext?

We always use SpContext.Current.Web, but then what is difference between httpcontext and spcontext?
1
vote
1answer
3k views

SharePoint Foundation 2013 - Problem with loading sp.js and sp.runtime.js

I have problem with an order in which I am loading <script type="text/javascript" src="/_layouts/15/sp.js"></script> <script type="text/javascript" src="/_layouts/15/sp.runtime.js">...
6
votes
4answers
4k views

Custom Sign In Page has an SPContext.Current that is always null

Found the Solution The solution was to add a Root Site Collection (as the code was running in a sub-site, without a root site). See This Solution Important Update (based on feedback ...
2
votes
2answers
14k views

What is difference between SPContext.Current.Web.URL and SPContext.Current.Site when using SPSite object?

SPSite spsite1=new SPSite(SPContext.Current.Web.URL); SPSite spsite2=SPContext.Current.Site; What is the difference and when do we decide which one to use? I feel both give us the site collection ...
0
votes
1answer
2k views

Get Context through REST call

I know that in SharePoint 2013 with JavaScript, you can load the current context like so... var context = SP.ClientContext.get_current(); var user = context.get_web().get_currentUser(); context.load(...
0
votes
1answer
1k views

SPWeb.GetList issue on SPContext.Current.Web

When I call SPContext.Current.Site.RootWeb.GetList(someListUrl) I get a System.Runtime.InteropServices.COMException, but when I call the same method from a new SPWeb instance, it runs fine - why? // ...
0
votes
1answer
456 views

Current user doesn't change in webservice after another user signs in

The context: I have this web service hosted in SharePoint. [ServiceContract] public interface IUserService { [WebInvoke(UriTemplate = "/GetCurrentUser", Method = "GET", BodyStyle = ...
1
vote
2answers
129 views

When to call Dispose if passing SPContext.Site to a class library?

I'm just looking for a bit of sanity check on this one! I'm looking at many classes that have SPSite or SPWeb as a constructor for the class. The class is instantiated using SPContext.Site as the ...
1
vote
2answers
4k views

Getting page title in page layout

I am using the following code to get page title of current page in Page Layout but it is not working. <asp:Literal runat="server" text="<%$SPContext.Current.Item['Title']%>"></asp:...
5
votes
1answer
7k views

SPContext.Current is NULL for IHttpHandler

I am trying to implement IHttpHandler in SharePoint 2010 and for reference I am using this: http://blogs.msdn.com/b/kaevans/archive/2010/08/04/deploying-an-asp-net-httphandler-to-sharepoint-2010.aspx ...
0
votes
2answers
153 views

Accessing list from variation

I retrieve all the lists in the current web using: foreach (SPList list in SPContext.Current.Web.Lists) {} This works well. The problem is that when a user changes languages, and is routed to the ...
2
votes
4answers
3k views

sharepoint 2010 context menu event handler

i want to hide sharepoint 2010 list/library context menu based on users. i am using below javascript $(document).ready(function(){ $('.ms-MenuUIPopupBody').live('blur', function() { ...
0
votes
1answer
786 views

Web.GetListItem with a non list URL breaks SPContext

We have a bit of a weird issue and i was wondering if anyone had any insight on why the issue was occurring. We have a page deployed into the SharePoint root which has a custom webpart which would ...
2
votes
1answer
1k views

Calling SP.ClientContext in a loop Javascript

I'm looping through a number of sites to run a query that checks whether new content has been added to document libraries in that site in the previous three days. However, I'm having problems. When I ...
2
votes
1answer
5k views

Accessing a list from app web on host site generates access denied

I am trying to get title of a list which is located on Host Site from an SharePoint hosted app by using csom (javascript). I have added permission on Manifest file and chose the list but still getting ...
2
votes
3answers
6k views

Is there an alternative to SPContext.Current.Web.CurrentUser?

I have found that SPContext.Current.Web.CurrentUser is really unreliable. One out of ten requests that object comes back as null. Is there an alternative to SPContext.Current.Web.CurrentUser? Has ...
2
votes
2answers
982 views

How to determine item ContentType in FormControl (FieldIterator for instance)?

I've implemented my ListFieldIterator to change the way field controls rendered. I'd like to change the behaviour of form depending on the item content type, but any attempts to determine ...