Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

System.Net.WebException: The remote server returned an error: (401) Unauthorized.

$
0
0

Hello,

I have provider hosted app created in VS 2013.Whenever I start running the application, It throws following error :

 System.Net.WebException: The remote server returned an error: (401) Unauthorized.

at following code line :

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

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

                    clientContext.ExecuteQuery();

                    ViewBag.UserName = spUser.Title;

                    ViewBag.IsSiteAdminBool = spUser.IsSiteAdmin;
                }
            }

Can anyone please help me to resolve this ???

Note : 

1) VS 2013 is running using RUN AS ADMINISTRATOR 

2) User1 is logged in SharePoint Server who is site administrator in SharePoint Web

3) Web App Pool is running under Farm account

4) User1 is local Administrator group in SharePoint Server

Please let me know if any further information is required.

Your help will be highly appreciated.

Thanks and Regards,


Dipti Chhatrapati


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>