First create a new empty project Project1
Add a WebForm1
Write the following code
Private void page_load (object sender, system.eventargs e) {if (session ["userid"]! = null) {this.response.write (session ["username"]. Tostring ());} else {this.Response .Write ("You entered the username or password is incorrect!");}}
In the project name, you can fill a new Webserve login.asmx
The code file is as follows
Using system; using system.componentmodel; using system.data; using system.web; using system.web.services;
Namespace Workflow {///
#Region Component Designer Generated Code // Web Server Designer The private icontainer component = null; ///
///
[WebMethod (EnableSession = true)] Public Bool Loginmethod (String UserName, String Password) {if (username == "admin" & password == "admin") {session ["username"] = "admin"
Return True;
}
Return false;}}}
Built a new web project, WebProject1
Add login's web reference, and call LoginMethod in WebForm1, if the return value is true to redirect to Project1 WebForm1.aspx
Pay attention to two points here
One: Enjoy the description of EnableSession = true in the feature of WebService: If you are a Web project that you have now, you will not allow you to add new WebService, this time you have to build a webservie file in other locations. , Then add this existing file in your project.
Write a bad writing, please forgive