checking for secure connection and rediecting

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Hello

I am having a problem checking for a secure connection.

Checking Request.ServerVariables["HTTPS"] works OK, but
Request.IsSecureConnection always returns true, which seems weird to
me to say the least.

Any advice ?

Thanks
Rob
 
Hi Rob,
I tested Request.IsSecureConnection with a non-secure connection and it
returns me false.
For eg:
bool test=Request.IsSecureConnection;
I got the value of test boolean variable as false for
http.Make sure your connection again before testing as
the value indicates whether you use secure sockets(https) or not.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
 
Hi Marshal

Thanks for your reply. To clarify, in my code I have this:

void Page_Load(Object Sender, EventArgs e)
{
if ( Request.IsSecureConnection )
{
// do stuff
// never gets here
}
else if ( Request.ServerVariables["HTTPS"].ToLower() == "on" )
{
// do stuff
// gets here OK ! !
}
}

So in the same Page_Load fucntion how can Request.IsSecureConnection be
false, yet Request.ServerVariables["HTTPS"].ToLower() be "on"

? ? ? ?

Thanks again
Rob
 
Hi Robert,
I tested it with a secure connection(https) to make sure and it returns
true,that means it is working just fine.
What I can think of is your ssl certificate may have some problem.It may not
be a valid certificate.
There is lot of security built into .NET Framework and that could cause
Request.IsSecureConnection not to work
as expected with a certificate which is not valid.
Check your certificate first and if you have certificate which is
not valid,put a valid certificate .
The Request.ServerVariables["HTTPS"] works for you,may be because the .NET
Framework security is not playing a role there.
Somebody at Microsoft can explain better.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
 
Back
Top