只有在登录页面设置SSL页面 [英] Setting up SSL page only on login page

查看:185
本文介绍了只有在登录页面设置SSL页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立SSL页面只有登录页面。我该怎么办呢?我一指这篇文章:

I want to set up SSL page for only login page. How can I do it? I a referring this article:

<一个href=\"http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx\" rel=\"nofollow\">http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx

但这个环节设置了SSL对整个网站这是从来没有明智的。我如何才能启用它登录页面或需要安全信息的页面。我使用IIS 7.5,Asp.Net 4.0

But this link sets up SSL on whole website which is never advisable. How can I just enable it for login page or other pages where secure information is needed. I am using IIS 7.5, Asp.Net 4.0

推荐答案

一个简单的方法是检查该网页是安全的,当你进入登录页面,登录到他重定向非安全网页后。

One simple way is to check if the page is secure when you entering the login page, and after the login to redirect him on a non secure page.

您可以检查网页是否安全使用此命令

You can check if the page is secure by using this command

HttpContext.Current.Request.IsSecureConnection

IsSecureConnection ,居然检查网址开头的 https://开头

The IsSecureConnection, actually check if the url starts with https://

有关exampe,如果添加此登录页面上,在pageLoad的或初始化所能做的工作。

For exampe, if you add this on login page, on PageLoad or on init can do the work

if(!HttpContext.Current.Request.IsSecureConnection)
{
  Response.Redirect(Request.Url.Replace("http://","https://"),true);
  return;
}

但你需要的时候你离开登录页面,以他重定向到非安全页面。

But then you need to redirect him to the non secure page when you leave the login page.

一个更复杂的方式,但更多的肯定,就是使用code,它不但要检查一个页面,但在规则的所有网页的基础。我的建议是code,我个人是:

One more complex way, but more sure, is to use a code that check not only one page, but all pages base on rules. I suggest this code that I personally use :

<一个href=\"http://www.$c$cproject.com/KB/web-security/WebPageSecurity_v2.aspx\">http://www.$c$cproject.com/KB/web-security/WebPageSecurity_v2.aspx

和结果
HTTP://$c$c.google.com/p/securityswitch/

PS中的SSL是与非SSL网页并行地运行,不同的端口上。其高达你在哪里浏览你的用户。所以没有只有一个页面SSL选项。

Ps The SSL is run in parallel with the non ssl pages, on different port. Its up to you where to navigate your users. So there is not "only one page ssl" option.

这篇关于只有在登录页面设置SSL页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆