Thursday, December 13, 2018

ASP .NET MVC Application - HTTP Error 403.14 – Forbidden

Here are few reasons to get “HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.” error in ASP .NET Web application.



1. ASP.NET not registered on the server. To fix it, execute following command in command prompt:
Windows 32bit
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

Windows 64bit
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

2. Wrong .NET version (v2.0 instead of v4.0) is configured on the web site application pool. To fix it, find the Application Pool of the website, go to Advanced Settings and make sure that the .NET Framework version value v4.0 is selected.

3. Wrong IIS directory permissions. To fix it, make sure App Pool user has enough permission to the website directory.

Also make sure connection strings in the web.config are correct and there is no missing DLLs in the bin folder.

Wednesday, April 11, 2018

SharePoint Online - Make Office File to Open in Desktop Application by default Instead of Online

In a SharePoint documents library, documents will be opened in client application by default, if the “Open Documents in Client Applications by Default site” site collection feature is activated.






However, if you use document URL as a link in another place, clicking the link will not open document in desktop application. It will open the document in online app.

Solution for that is, add respective Office URI Scheme to the beginning of the document URL. For a Excel document, link should be like: ms-excel:ofe|u|https://abc.sharepoint.com………
List of URL scheme names available for Microsoft Office applications are:
  • ms-word:
  • ms-powerpoint:
  • ms-excel:
  • ms-visio:
  • ms-access:
  • ms-project:
  • ms-publisher:
  • ms-spd:
  • ms-infopath:

Sample jQuery code to open an Excel document in desktop application on a button click is:
$("#btnOpenExcelFile" ).click (function() {
window.open( "ms-excel:ofe|u|https://abc.sharepoint.com/:x:/r/sites/BD/Shared%20Documents/Submissions%20List%20(Excel).xlsx?d=wda689ae3bb824932b2fd607a7870b107&csf=1&e=xTBvDI");
});


Friday, January 12, 2018

SharePoint Online - Client Side People Picker – JavaScript

Following code sample is an example of how to use People Picker controls in a SharePoint online custom form. Just add a Script Editor webpart to a page and add following code. Hitting ‘Test on Console’ button will log selected people’s names in the browser console.

In addition to name, there are other properties that you can directly use as shown in the following image.


Complete code to place in the Script Editor webpart:

< script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
< script src ="/_layouts/15/SP.Runtime.js"></script>
< script src ="/_layouts/15/sp.js"></script>
< script src ="/_layouts/15/1033/strings.js"></script>
< script src ="/_layouts/15/clienttemplates.js"></script>
< script src ="/_layouts/15/clientforms.js"></script>
< script src ="/_layouts/15/clientpeoplepicker.js"></script>
< script src ="/_layouts/15/autofill.js"></script>
< script src ="/_layouts/15/SP.Core.js"></script>
 
< div >
  <p><span>On behalfof:</span></p>
  <divid="peoplePickerDivOnBehalfOf"></div>
  <p><span>ApproverName:</span></p>
  <divid="peoplePickerDivApprover"></div>
 
  <inputtype="button"value="Test in Console" onclick =" ViewFieldData ( )"/>
</div>
 
<scripttype ="text/javascript">
$(document).ready( function() {
 
// Initialize People Pickers after loading clientpeoplepicker.js file.
SP.SOD.executeFunc( "/_layouts/15/clientpeoplepicker.js","SP.ClientContext",function() {
setTimeout( function() {
initializePeoplePicker( 'peoplePickerDivApprover');
initializePeoplePicker( 'peoplePickerDivOnBehalfOf');
}, 2000);
});
});
 
  // Render and initialize the client-side People Picker.
  function initializePeoplePicker(peoplePickerElementId) {
// Create a schema to store picker properties, and set the properties.
   var schema = {};
schema[ 'PrincipalAccountType'] ='User,DL,SecGroup,SPGroup';
 
// To specifies where you would want to search for the valid values
schema[ 'SearchPrincipalSource'] = 15;
 
// To specifies where you would want to resolve for the valid values
schema[ 'ResolvePrincipalSource'] = 15;
schema[ 'AllowMultipleValues'] =true;
schema[ 'MaximumEntitySuggestions'] = 50;
schema[ 'Width'] ='280px';
// Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial PickerEntity
// objects to set the picker value, and a schema that defines picker properties.
this .SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
  }
 
  function ViewFieldData() {
var peoplePickerApprover=this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDivApprover_TopSpan;
var peoplePickerOnBehalfOf=this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDivOnBehalfOf_TopSpan
//var keysApprover = peoplePickerApprover.GetAllUserKeys();
//var keysOnBehalfOf = peoplePickerOnBehalfOf.GetAllUserKeys();
 
// Read the first person selected
var userApproverText='';
var userApprover = peoplePickerApprover.GetAllUserInfo();
if (userApprover.length > 0) {
var userA=userApprover[0];
 
// Read DisplayText property. There are few other properties available too
userApproverText = userA.DisplayText;
}
 
// Read all people selected
var userOnBehalfOfText='';
var userOnBehalfOf = peoplePickerOnBehalfOf.GetAllUserInfo();
if (userOnBehalfOf.length > 0) {
for ( var i = 0; i < userOnBehalfOf.length; i++) {
var userB = userOnBehalfOf[i];
 
if (i == 0) {
userOnBehalfOfText += userB.DisplayText;
} else{
userOnBehalfOfText += ( '; '+userB.DisplayText);
}
}
}
 
console.log( "Approver: "+userApproverText);
console.log( "On behalf of: "+userOnBehalfOfText);
  }
</script>