Umbraco - C# - Redirect a Umbraco Page to an external web site.

Umbraco - C# - How to Redirect a Umbraco Page to an external web site.

Two create a redirect from a Umbraco page to an exteral site you need to:   (this is very simple)

 Step 1) Add the page to Umbraco that you want to rediect. (You may want to Hide this page from navigation)

 Step 2) Create a new Web Form in C# Visual Studio
     (this web form will be placed in the route of the site)

 Step 3) Update the Web Config to include the new file mentioned in step 2
     (or you will get a Server error in appliaction)

 Step 4) Add a Url redirect to the UrlRewriting.config,  from the Umbraco page (created in step 1), to the web form (created in step 2).

Step 2: Here is the C# Code (my-redirect-example.aspx) form for step 2:

(it is basically a blank form)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="my-redirect-example.aspx.cs" Inherits="my_redirect_example" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
  <body onload="open_on_entrance()">
   <form id="form1" runat="server">


Here is the C# Code (my-redirect-example.aspx.cs) form for step 2:  

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class my_redirect_example : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

Step 3: Here is the line you need to add to the Web Config file for step 3:

Add this in your <appSettings> section.

   <add key="umbracoReservedUrls" value="~/my-redirect-example.aspx" />

Step 4: Here is the Code you need to add to the UrlRewriting.config file:


Note:  Highlighted Yellow,  ^~/my-page.asp  . This is the name of the Umbraco Page you create in Step 1.  

If you experience any issues with this code, please let me know....


Post a Comment

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco