I have to give support on SharePoint 2013 app solution. Since the certificate had expired I used the instructions in this article from Microsoft to create a certificate and run the app from Visual studio. However, I am getting the following error:

Server Error in '/' Application.
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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

Source Error: 

Line 36:             {
Line 37:                 clientContext.Load(clientContext.Web, web => web.Title);
Line 38:                 clientContext.ExecuteQuery();
Line 39:                 Response.Write(clientContext.Web.Title);
Line 40:             }

Source File: c:\users\abc1\documents\visual studio 2015\Projects\SharePointApp2\SharePointApp2Web\Pages\Default.aspx.cs    Line: 38 

Stack Trace: 

[WebException: The remote server returned an error: (401) Unauthorized.]
   System.Net.HttpWebRequest.GetResponse() +1399
   Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute() +37
   Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) +615
   Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery() +47
   Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery() +89
   Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() +305
   SharePointApp2Web.Default.Page_Load(Object sender, EventArgs e) in c:\users\abc1\documents\visual studio 2015\Projects\SharePointApp2\SharePointApp2Web\Pages\Default.aspx.cs:38
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

What am I doing wrong? How can I create a certificate and use it in a Provider hosted app in visual studio?

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.