-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedirectRouteHandler.cs
More file actions
32 lines (29 loc) · 988 Bytes
/
RedirectRouteHandler.cs
File metadata and controls
32 lines (29 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using EPiServer.Util;
using System;
using System.Web;
using System.Web.Compilation;
using System.Web.Routing;
namespace Gosso.EPiServerAddOn.QuickNavExtension
{
public class RedirectRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var logout = BuildManager.CreateInstanceFromVirtualPath("/Util/Logout.aspx", typeof(Logout)) as Logout;
if (logout == null)
{
// Something seems wrong
throw new Exception();
}
logout.PreRender += this.LogoutOnPreRender;
return logout;
}
private void LogoutOnPreRender(object sender, EventArgs eventArgs)
{
var returnUrl = HttpContext.Current.Request.QueryString["ReturnUrl"];
if (string.IsNullOrEmpty(returnUrl))
returnUrl = "/";
HttpContext.Current.Response.Redirect(returnUrl);
}
}
}