Skip to main content
deleted 22 characters in body; edited title
Source Link
Sadanand
  • 145
  • 3
  • 11

The name 'SharePointContextProvider' does not exist in' does not exist in the current context

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist inin the current context.

Here is my actual code.

    public ActionResult Index()
    {
        User spUser = null;

        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context.

Here is my actual code.

    public ActionResult Index()
    {
        User spUser = null;

        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

The name 'SharePointContextProvider' does not exist in the current context

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in the current context.

Here is my actual code.

    public ActionResult Index()
    {
        User spUser = null;

        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

added 9 characters in body
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 53
  • 79

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context.

Here is my actual code.

The name 'SharePointContextProvider' does notpublic existActionResult in'Index()
 does not exist in{
 the current context.     User spUser = null;

Here is my actual code.

public ActionResult Index() { User spUser = null;

 
        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context.

Here is my actual code.

public ActionResult Index() { User spUser = null;

        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context.

Here is my actual code.

    public ActionResult Index()
    {
        User spUser = null;
 
        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.

Source Link
Sadanand
  • 145
  • 3
  • 11

The name 'SharePointContextProvider' does not exist in' does not exist in the current context

I have a Basic Provider Hosted App (which is an on premise hosted app). It has been integrated with SP2013 and hello world Page is working fine. But when I wanted to develop the actual part, I have to use SharePointContextProvider, but the compiler is throwing an error.

The name 'SharePointContextProvider' does not exist in' does not exist in the current context.

Here is my actual code.

public ActionResult Index() { User spUser = null;

        var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

        using (var clientContext = spContext.CreateUserClientContextForSPHost())
        {
            if (clientContext != null)
            {
                spUser = clientContext.Web.CurrentUser;

                clientContext.Load(spUser, user => user.Title);

                clientContext.ExecuteQuery();

                ViewBag.UserName = spUser.Title;
            }
        }

        return View();
    }

In View I want to use the User Name. I am using VS 2012 and SP 2013.