Asp.net ssl yönlendirme
15 Haziran 2016 / 12:08
Burak
Merhaba arkadaşlar kimi zaman sitelerimizde ssl sertifikası kullanarak yönlendirme yapmamız gerekebilir işte böyle durumlarda en kolay yöntem web.config üzerinden rule oluşturmaktır.Aşağıdaki rule ile sizlerde düz http olarak gelen requestleri , ssl olarak yönlendirebilirsiniz.
1.Yol
1 2 3 4 5 6 |
string RequestPath = HttpContext.Current.Request.Url.ToString(); if (RequestPath.StartsWith("http://")) { RequestPath = RequestPath.Replace("http://", "https://"); HttpContext.Current.Response.Redirect(RequestPath, true); } |
2.Yol
1 2 3 4 5 |
if(!Request.IsSecureConnection) { string redirectUrl = Request.Url.ToString().Replace("http:", "https:"); Response.Redirect(redirectUrl); } |
3.Yol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<system.webServer> <rewrite> <rules> <clear /> <rule name="Redirect to https" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> |
Etiketler: asp.net http to https redirect rule, asp.net ssl redirect, asp.net ssl redirect rule, asp.net webconfig ssl redirect, asp.net webconfig ssl rule
Bu Yazılarıda Okuyabilirsiniz...
Bir cevap yazın