RedirectToUrl.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RedirectToUrl.ascx.cs" Inherits="SitefinityWebApp.UserControls.RedirectToUrl" EnableViewState="false" %>
RedirectToUrl.ascx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Web.UI;
namespace SitefinityWebApp.UserControls
{
public partial class RedirectToUrl : System.Web.UI.UserControl
{
public string DestinationUrl { get; set; }
public bool PermanentRedirect { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
bool inDesignMode = this.IsDesignMode();
if (!String.IsNullOrWhiteSpace(DestinationUrl))
{
if (inDesignMode)
{
Output.Text = Server.HtmlEncode("Redirect to " + DestinationUrl);
}
else
{
if (PermanentRedirect)
{
Response.RedirectPermanent(DestinationUrl, false);
}
else
{
Response.Redirect(DestinationUrl, false);
}
}
}
else
{
if (inDesignMode)
{
Output.Text = "Warning: No redirect URL found";
}
else
{
Output.Text = "";
}
}
}
}
}
No comments:
Post a Comment