I need to redirect from htttp://metroyapi.com.tr or/and "http://www.metroyapi.com.tr" to https://www.metroyapi.com.tr.
I already tried the following methods but none of them worked.
At Startup:
app.Use(async (context, next) =>
{
if (context.Request.IsSecure) {
await next();
} else {
var withHttps = Uri.UriSchemeHttps + Uri.SchemeDelimiter + context.Request.Uri.GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Scheme, UriFormat.SafeUnescaped);
context.Response.Redirect(withHttps);
}
});
At Global.asax:
if (!Context.Request.IsSecureConnection)
Response.Redirect(Context.Request.Url.ToString().Replace("http:", "https:"));
and
if (!HttpContext.Current.Request.IsSecureConnection) {
Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"]
+ HttpContext.Current.Request.RawUrl);
}
At FilterConfig:
filters.Add(new RequireHttpsAttribute());
and bunch of web.config solution.
None of them worked I still get 404 error.
Any suggestions?
Help is much precited!