Enabling Frame Redirection in Azure
This little tip is about how to enable "Frame Redirection" when using Azure App Services
Introduction
This little tip is about how to enable "Frame Redirection" when using Azure App Services. You can obtain more information about what redirection is by clicking here.
The Problem
I came across this problem when I registered a new domain. I wanted to redirect that domain using "Frame Redirection" to return my personal site in Azure. So, the redirection wasn't working because Azure adds by default (or at least I think so) an "X-FRAME-OPTIONS
" header with a "SAMEORIGIN
" value. This means that, by default, "Frame redirection" is not allowed.
The Solution
To solve the problem, you just need to add this little piece of code to your Global.asax file:
private void Application_EndRequest(object sender, EventArgs e)
{
Response.Headers["X-FRAME-OPTIONS"] = "ALLOW-FROM url1,url2;
}
As you can see above, "X-FRAME-OPTIONS
" header is replaced with the keyword "ALLOW-FROM
" and the list of authorized urls delimited by commas. By doing this, I solved the problem and the redirection is working properly now.