Check the login information in ASP. NET and use the global process pcsky (original)

Source: Internet
Author: User

'Written in module1.vb and can be called by any page
'Vs. NET 2003 setup, test passed
'Pcsky (Jin Ge) http://blog.csdn.net/lee2001xp

This can also be written in. net. It is not recommended
If SESSION ("username") "then
Response. Redirect ("login. aspx ")
End if
%>

ASP. NET written in module1.vb
Module module1
Sub checkuser () 'check user information
If httpcontext. Current. Session ("username") = "" then
Httpcontext. Current. response. Redirect ("login. aspx ")
End if
End sub
End Module

Add the following to the page for verification:
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
Call checkuser () 'to check logon information
End sub

Advantages:
1. Implement the page andCodeTo improve performance.
2. Code standardization, using global processes to reduce code Redundancy

The example is relatively simple. I hope you can give me some advice! Pai_^

Related Article

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.