개발및업무/C#
[asp.net] http를 https로 변경 하는 방법
H0IT
2011. 10. 19. 09:42
728x90
1. 403.4번 에러 페이지를 작성하는 방법
http://www.jppinto.com/2009/01/automatically-redirect-http-requests-to-https-on-iis-6/
HTML 파일로 에러 페이지 작성하는 방법.
<!-- beginning of HttpRedirect.htm file --> <script type= "text/javascript" > function redirectToHttps() { var httpURL = window.location.hostname+window.location.pathname; window.location = httpsURL ; } redirectToHttps(); </script> <!-- end of HttpRedirect.htm file --> |
2. 서버에서 iis 관리자 접속 -> ssl 설정 --> ssl필요 체크를 푼다.
소스에서 아래 코딩 추가 한다.
//http 연결에서 보안 소켓 사용 여부를 가져오는 로직
if (!Request.IsSecureConnection)
{
string redirectUrl = Request.Url.AbsoluteUri.Replace("http:", "https:");
Response.Redirect(redirectUrl);
}
if (!Request.IsSecureConnection)
{
string redirectUrl = Request.Url.AbsoluteUri.Replace("http:", "https:");
Response.Redirect(redirectUrl);
}
728x90