Thursday, April 7, 2011

Checking whether page is secure or not in ASP.NET or JavaScript

Recently in one the project we require to check whether page is secure or not as we are going to open a new popup window from that page and that why we need to pass https protocol if we have that page secure. I have search lots of things on internet and I have found following ways of finding whether page is secure or not in ASP.NET or JavaScript.

In ASP.NET There are two way of doing it. Either we can use current request to check whether it is secured or not or we can use server variables to check whether it it secure or not just like following.

Here in above code If this returns true then Page is secured otherwise it is not Or you can use following server variable to check the protocol.
In JavaScript you can document.location.protocol to check whether page is secure or not. Just like following.
So you can see its very easy to check whether page is secure or not. Hope you liked it… Stay tuned for more..
Shout it
kick it on

1 comment:

  1. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#,, php tutorial, Ms sql server

    Thanks a lot..!


Your feedback is very important to me. Please provide your feedback via putting comments.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog


My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews