User control user logon judgment

Source: Internet
Author: User
Use the user control whelogined. ascx, Code As follows:


Namespace Hezjs. webform. modules. ascx

{

  Using System;

  Using System. Data;

  Using System. drawing;

  Using System. Web;

  Using System. Web. UI. webcontrols;

  Using System. Web. UI. htmlcontrols;

  /**/ /// <Summary> 

 ///A summary of modwhelogined.

 /// </Summary> 

  Public   Class Modwhelogined: system. Web. UI. usercontrol

  {


Private   Void Page_load ( Object Sender, system. eventargs E)

{

// Place user code here to initialize the page



String Strpath = Hezjs. webform. wffunction. siteurl ( This . Parent. Page) +   " Modules/aspx/modlogin. aspx " ;


If ( This . Session [ " Transfer page " ] =   Null )

This . Session. Add ( " Transfer page " , This . Parent. Page. Request. rawurl );

Else  

This . Session [ " Transfer page " ] =   This . Parent. Page. Request. rawurl;


If ( This . Session [ " User " ] ! =   Null )

{

If (Hezjs. SYS. sysuser) This . Session [ " User " ]). Logined)

{

//Determine Permissions

//Specify a style

}  

Else  

{

This. Response. Redirect (strpath );

}  

}  

Else  

This . Response. Redirect (strpath );


}  


Code generated by web Form Designer # Region Code generated by web Form Designer

Override   Protected   Void Oninit (eventargs E)

{

// 

//Codegen: This call is required by the ASP. NET web form designer.

// 

Initializecomponent ();

Base. Oninit (E );

}  



/**/ /// <Summary> 

///The designer supports the required methods-do not use the code editor

///Modify the content of this method.

/// </Summary> 

Private   Void Initializecomponent ()

{

This. Load+ = NewSystem. eventhandler (This. Page_load );


}  

# Endregion  

}  

}  


Strpath is used to specify the system logon interface. The hezjs. webform. wffunction. siteurl () method is used to return the website address.

Address of the page for storing user requests in session ["transfer page "]

Session ["user"] stores a hezjs. SYS. sysuser object, which includes a logined member to return whether the user has logged on

Drag and Drop the user control directly to each page for Logon. When a user requests this page, if the user is not logged on, the user will go to the logon page. If the user has logged on, the user will be browsed normally.

Is it convenient?

You can also judge the permission of the Request page and specify the general style of the page (if no style is specified in advance) in the area marked by the code above ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.