Click here to Skip to main content
15,886,795 members
Articles / Hosted Services / Azure
Tip/Trick

Enabling Frame Redirection in Azure

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
24 Nov 2016CPOL 6.1K   2  
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:

C#
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Spain Spain
Telecommunication Engineer by University of Zaragoza, Spain.

Passionate Software Architect, MCPD, MCAD, MCP. Over 10 years on the way building software.

Mountain Lover, Popular Runner, 3km 8'46, 10km 31'29, Half Marathon 1h08'50, Marathon 2h27'02. I wish I could be able to improve, but It's difficult by now

Comments and Discussions

 
-- There are no messages in this forum --