SharePoint Provider-Hosted App - 401 Unauthorized error on clientContext.ExecuteQuery()

So you are ready to develop a SharePoint app and have followed this MSDN article to get everything set up. F5 in visual studio, clicked Trust It to "Do you trust <name of your app>?" from SharePoint, and then you are getting 

The remote server returned an error: (401) Unauthorized


Chances are the IssuerId in provider-hosted application web.config is listed as a UPPER CASE Guid string. 



Offline install of Office Developer Tools for Visual Studio 2012

Last week Microsoft has released the RTM version of Office Developer Tools for Visual Studio 2012. This is a very exciting news for those SharePoint 2013 developers who has been using Preview 2 version of the tool (made to GA on Nov/2012) since SharePoint 2013 RTM.

For those who don’t need to worry about the offline installation and just want to install it on one or two development machines – here is the link to download and install directly through Microsoft’s Web Platform Installer (Web PI) http://aka.ms/OfficeDevToolsForVS2012

However, please continue reading if you like to:

1. keep a shadow copy of whole installation package along with all the pre-requirements components

2. able to install Office Developer Tools for Visual Studio 2012 in one or more offline environments

3. save some internet bandwidth for your enterprise network

Here is what you need to do:

*You will need a PC with Microsoft Web Platform Installer 4.5 installed and connected to the internet to download the initial copy of whole package.

Step 1. Download the Package through WebpiCmd.exe command (Online)

From the Web PI wizard you can see there are multiple dependency components needs to be installed as part of Microsoft Office Developer Tools for Visual Studio 2012




Here is the WebpiCmd command that you can use to avoid  to download each these dependencies one by one manually.

*WebpiCmd is locate at “C:\Program Files\Microsoft\Web Platform Installer” on the machine that has Web PI 4.5 installed

WebpiCmd.exe /offline /products:OfficeToolsForVS2012RTW /Path:C:\YourFolder\OfficeToolsForVS2012RTW



How to use ASP.NET AJAX UpdatePanel in ModalPopup

This design not only shows you how to use ASP.NET UpdatePanel inside ModalPopup, it also shows a way of having multiple dynamically created controls that act as triggers to show ModalPopup, and the content of ModalPopup will change depending on the control that triggered the Popup. Then user can perform an action that does partial update inside the ModalPopup. You will only need one ModalPopupExtender control by using this design.

The following diagram shows how the controls are structured in the .aspx page


As you can see here, we have an UpdatePanel inside the ModalPopup, and the ModalPopup is in the another UpdatePanel along with other dynamic controls on page.

The next diagram shows the actual look of the page.




Virtual Earth Map Control on SharePoint

James Tsai .Net SharePoint Blog Virtual Earth Map Control

Well, I finally have some free time to play with it. I know, I am two years late on this topic. But I still wanted to see how Microsoft Virtual Earth Map Control can work together with SharePoint, so I created a control that does following tasks

1. Read saved locations from SharePoint List

Read saved locations information from SharePoint list. SharePoint list stores location items with Title, Address and Description fields.

James Tsai .Net SharePoint Blog Address Book SharePoint List

Render all the locations stored in SharePoint list on Virtual Earth Map Control. Virtual earth Map Control is embedded in Content editor web part - there is no need to create a custom web part.

Display custom created panel control (VEMap Control) on Virtual Earth Map Control. It shows the pushpins, location Id and Titles - user click on the pushpin Id in panel control to see the corresponded location on map

James Tsai .Net SharePoint Blog Virtual Earth Map Control View Mode

2. Write to SharePoint List

Display Pushpin Information box when user click on pushpins – information box contains the custom created HTML with Text boxes and Edit/Save/Cancel action links.

Push changed value back to SharePoint list via SharePoint list web service (/_vti_bin/lists.asmx)

James Tsai .Net SharePoint Blog Virtual Earth Map Control Edit Mode

How to do it

Download JavaScript Files



Where do you deploy custom SharePoint web service files to? (.asmx, disco.aspx and wsdl.aspx)

Recently someone asked me to troubleshoot the problem he had with the custom web service he created.

He followed the instructions from MSDN article "Walkthrough: Creating a Custom Web Service" and generated MyWebservice.asmx, MyWebservicedisco.aspx and MyWebservicewsdl.aspx files. He also made changes to contract reference and SOAP address in both disco.aspx and wsdl.aspx to provide the necessary redirection and maintain the URL virtualization.

Web service was deployed to 12\TEMPLATE\LAYOUTS in file system and can be viewed from URL http://<site>/_layouts/MyWebservice.asmx or http://<site>/<subsite>/_layouts/MyWebservice.asmx without any issues.

"Everything looks fine except..." - he said

At this stage I knew what the problem was and his description of the problem confirmed it.

"Everything looks fine except the web service function call returns an incorrect and unexpected result"

Yes, it could be the code logic errors. But I sticked to the one obvious mistake he has made. I told him that "Only deploy your custom web service files to 12\ISAPI (\_vti_bin\) folder unless you know what you are doing"

I have seen this problem many times before from different developers, third party vendor's and IT supports. They all have their own reasons (wrong reasons) for not to deploy their custom web service files to 12\ISAPI.

Why _vti_bin folder