I recently created a custom service application administration page which collected a username and password of a service account. I wanted to display a warning to the user if they were not on a secure HTTPS channel, similar to the one that SharePoint provides when you attempt to start the User Profile Synchronization service. In looking at the out of box pages in the ADMIN directory, the code that SharePoint uses is quite simple:
1 2 3 4 5 6 7 8 |
<div id="SslWarning" style="color:red;display:none"> <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,SSL_warning%>" EncodeMethod="HtmlEncode"/> </div> <script language="javascript"> if (document.location.protocol != 'https:') { var SslWarning = document.getElementById('SslWarning'); SslWarning.style.display = ''; } </script> |