DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

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

Jalpesh Vadgama user avatar by
Jalpesh Vadgama
·
Apr. 07, 11 · · News
Like (0)
Save
Tweet
7.04K Views

Join the DZone community and get the full member experience.

Join For Free

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.

HttpContext.Current.Request.IsSecureConnection

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.

Request.ServerVariables["SERVER_PROTOCOL"];

In JavaScript you can document.location.protocol to check whether page is secure or not. Just like following.

document.location.protocol=='https:'

So you can see its very easy to check whether page is secure or not. Hope you liked it… Stay tuned for more..

ASP.NET security JavaScript

Published at DZone with permission of Jalpesh Vadgama, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • JUnit 5 Tutorial: Nice and Easy [Video]
  • Implementing RBAC Configuration for Kubernetes Applications
  • What Is Lean Software Development
  • Testing Schema Registry: Spring Boot and Apache Kafka With JSON Schema

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo