I have an Umbraco environment version 7.9.0 and I have this code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
// This page shows nothing, only redirects to index page.
var indexPage = Model.Content.GetPropertyValue<IPublishedContent>("indexPage");
if (indexPage != null)
{
Response.Redirect(indexPage.Url, false);
}
else
{
var results = Model.Content.Children.Where(x => x.Name.ToLower() == "index");
if (results.Any())
{
Response.Redirect(indexPage.Url, false);
}
}
}
To put in context, I have two machines in two AWS servers and a AWS Load Balancer. The URL I am trying to reach is the URL of the load balancer and it decides which machine to use.
The problem is the Response.Redirect is giving a 302 code and I need to get a 301 so I changed Response.Redirect to Response.RedirectPermanent. After changing it the server is thowing a 503 error but if I remove the cookies it works again, and if I remove the cookies it throws the error again and so on.
Have you ever had this problem or something similar?
I tried to do it with IIS Rewrite Rules and the problem persists. It redirects to the URL I want but when I delete the cookies it throws a 503 error and if I delete the cookies again it works and so on. Have anybody ever had a similar problem?
Redirect 301 Server Error
Hello,
I have an Umbraco environment version 7.9.0 and I have this code:
To put in context, I have two machines in two AWS servers and a AWS Load Balancer. The URL I am trying to reach is the URL of the load balancer and it decides which machine to use.
The problem is the Response.Redirect is giving a 302 code and I need to get a 301 so I changed Response.Redirect to Response.RedirectPermanent. After changing it the server is thowing a 503 error but if I remove the cookies it works again, and if I remove the cookies it throws the error again and so on.
Have you ever had this problem or something similar?
Thank you
Hi Diego
To make 301 redirect use this code:
Btw, it's a bad idea to make redirects in views. Do it with IIS Rewrite Rules - https://our.umbraco.com/documentation/Reference/routing/iisrewriterules/
Thanks,
Alex
Hi Alex,
I tried to do it with IIS Rewrite Rules and the problem persists. It redirects to the URL I want but when I delete the cookies it throws a 503 error and if I delete the cookies again it works and so on. Have anybody ever had a similar problem?
Thank you.
Hi Diego
What cookie?
Alex
Hi Alex,
The cookies are AWSALB and AWSALBCORS both from Amazon Load balancer.
I didn't know that Amazon Load balancer adds cookies to the website.
Can you avoid it?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.