Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with custom attribute

Problem with custom attribute

Scheduled Pinned Locked Moved ASP.NET
helpdesignsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dilip H Patel
    wrote on last edited by
    #1

    Dear All, I have created a custom attribute class in app_code as: [System.AttributeUsage(System.AttributeTargets.Class,AllowMultiple=false)] public class Arrtib : System.Attribute { public Arrtib() { if (HttpContext.Current.Session["UserId"] == null) { HttpContext.Current.Server.Transfer("~/Login.aspx"); } } } And i have used this attribute as follows. [Arrtib] public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } the basic idea behind that is "if user is not log in then request for this page (default.aspx) will redirect to login page." this works fine in when we request default.aspx first time. but after login and once accessing the default.aspx page and then log off. (in log of i have cleared the session.) now if we request for the same page it should call the custom attribute constructor and redirected to login page. BUT..... ya BUT attribute constructor is not executing. Try to help for this problem. Thanks in Advance.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups