PageRenderTime 137ms CodeModel.GetById 132ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/App_Code/Control/ZaytonaClasses/Class1.cs

http://github.com/gmhawash/SSR
C# | 43 lines | 35 code | 7 blank | 1 comment | 8 complexity | 965aa6b45d2a140cbaae66b73e8a511c MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Web.UI;
 6using System.Web.Security;
 7
 8namespace ZaytonaClasses
 9{
10  public class ZPage : System.Web.UI.Page
11  {
12    protected static string _prevPage;
13    protected string PrevPage 
14    {
15      get {return _prevPage;}
16      set {_prevPage = value;}
17    }
18
19    protected override void OnLoad(EventArgs e)
20    {
21      if (!User.Identity.IsAuthenticated)
22        FormsAuthentication.RedirectToLoginPage();
23
24      if (!IsPostBack && Request.UrlReferrer != null && PrevPage != null)
25      if (!PrevPage.Trim().Equals(Request.UrlReferrer.OriginalString.Trim()))   // only replace if they are not the same exact link..
26        PrevPage = Request.UrlReferrer.OriginalString;
27
28      // Be sure to call the base class's OnLoad method!
29      base.OnLoad(e);
30    }
31
32    protected void Redirect(string url)
33    {
34      Response.Redirect(this.ResolveUrl(url));
35    }
36
37    protected void GoBack()
38    { 
39      Redirect (PrevPage == null ? "./Default.aspx" : PrevPage);
40    }
41
42  }
43}