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.collections;
Using system.componentmodel;
Using system.data;
Using system.diagnostics;
Using system.Web;
Using system.Web.services;
Namespace Workflow
{
///
A summary description of /// login.
/// summary>
Public class login: System.Web.Services.Webservice
{
WorkflowWebui.Portallogin.frameworkService loginservice = new workflowWebui.Portallogin.frameworkService ();
Public login ()
{
// Codegen: This call is necessary for the ASP.NET Web service designer.
InitializationComponent ();
}
#Region Component Designer Generated Code
/ / Web service designer necessary
Private icontainer Components = NULL;
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
/// summary>
Private vidinitiRizeComponent ()
{
}
///
/// Clean all the resources being used.
/// summary>
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing && Components! = NULL)
{
Components.dispose ();
}
Base.dispose (Disposing);
}
#ndregion
[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.