Friday 20 June 2014

The Security Token Service is unavailable

The Security Token Service is unavailable
An exception occurred when trying to issue security token: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error
Request for security token failed with exception: System.ServiceModel.ServiceActivationException: The requested service
An exception occurred when trying to issue security token: The requested service
All above errors are related to STS service.
Root Cause:
-SecurityTokenServiceApplication might be stopped.
Solution:
Go to IIS -->Sites--> SharePoint WebServices --> SecurityTokenServiceApplication
Click on 'Content View' down at the bottom
Right click on Securitytoken.svc
Click Browse
If you don't see any error then, you are good.
If you see any error like... Internet Explorer cannot display the web page, then you need to start STS service.
Right click on the SecurityTokenServiceApplication and click Explore, copy the web.config and compare the file with the below code.
If your file is matches with above one, then just reset IIS.
If you find a lot of changes in the web.config file on your Farm with above one, replace the file on SecurityTokenServiceApplication(please also have the copy of the original web.config), perform an IIS reset and check if the STS page comes as expected.
If your problem is not solved, try below...
Open SharePoint Powershell
Run the following commands one by one on SharePoint PowerShell:
$h = Get-SPServiceHostconfig
$h.Provision()
$services = Get-SPServiceApplication
foreach ($service in $services) { $service.provision();
write-host $service.name}
Now perform an IIS Reset and give another shot to browse the STS, and I'm sure you will see positive results!