使用webservice解决多系统登陆问题(收藏)
2005-02-14 21:12
661 查看
首先新建一个空项目project1
添加一个WebForm1
写如下代码
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["UserID"] != null)
{
this.Response.Write(Session["UserName"].ToString());
}
else
{
this.Response.Write("你输入的用户名或密码不正确!");
}
}
在项目名称上点又键,填加一个新webservie Login.asmx
代码文件如下
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace WorkFlow
{
/// <summary>
/// Login 的摘要说明。
/// </summary>
public class Login : System.Web.Services.WebService
{
WorkFlowWebUI.PortalLogin.FrameworkService loginService = new WorkFlowWebUI.PortalLogin.FrameworkService();
public Login()
{
//CODEGEN:该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
}
#region Component Designer generated code
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod(EnableSession=true)]
public bool LoginMethod(string userName,string password)
{
if(userName == "admin" & password== "admin")
{
Session["userName"] = "admin"
return true;
}
return false;
}
}}
再建一个新web项目,WebProject1
添加Login的web引用,并在webForm1中调用LoginMethod,如果返回值为true重定向到project1的WebForm1.aspx
这里需要注意两点
一:在webService的特性里面需要加入(EnableSession=true)的描述
二:如果你是现在已经有的web项目将不允许你向其中添加新的webservice,这时候你要先在其它位置建立一个webservie文件,然后在你的项目里面添加这个现有文件就可以了。
添加一个WebForm1
写如下代码
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["UserID"] != null)
{
this.Response.Write(Session["UserName"].ToString());
}
else
{
this.Response.Write("你输入的用户名或密码不正确!");
}
}
在项目名称上点又键,填加一个新webservie Login.asmx
代码文件如下
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace WorkFlow
{
/// <summary>
/// Login 的摘要说明。
/// </summary>
public class Login : System.Web.Services.WebService
{
WorkFlowWebUI.PortalLogin.FrameworkService loginService = new WorkFlowWebUI.PortalLogin.FrameworkService();
public Login()
{
//CODEGEN:该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
}
#region Component Designer generated code
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod(EnableSession=true)]
public bool LoginMethod(string userName,string password)
{
if(userName == "admin" & password== "admin")
{
Session["userName"] = "admin"
return true;
}
return false;
}
}}
再建一个新web项目,WebProject1
添加Login的web引用,并在webForm1中调用LoginMethod,如果返回值为true重定向到project1的WebForm1.aspx
这里需要注意两点
一:在webService的特性里面需要加入(EnableSession=true)的描述
二:如果你是现在已经有的web项目将不允许你向其中添加新的webservice,这时候你要先在其它位置建立一个webservie文件,然后在你的项目里面添加这个现有文件就可以了。
相关文章推荐
- 使用webservice解决多系统登陆问题
- 使用webservice解决多系统登陆问题(方法一)
- 使用webservice解决多系统登陆问题
- 使用webservice解决多系统登陆问题
- 使用webservice解决多系统登陆问题
- 使用中科院汉语分词系统ICTCLAS30.dll时出的问题,麻烦各位帮解决
- 解决windows无法使用系统搜索功能的问题
- win7 64位系统使用VS2010生成时出现中文目录乱码问题的解决方法【转】
- win7/8(32/64bit)系统下使用STC-ISP的问题与解决方法(MSCOMM32.OCX)
- Windows 10系统出现:“出现系统还原使用的卷影复制服务无法运行...”的问题解决
- 邮件系统安装与使用过程中各种报错与问题的详细解决方法
- 使用虚拟机克隆CentOS 6.9系统重启网卡报错问题的解决
- 解决putty终端中显示linux系统中C编程使用curses中文乱码的问题
- 广电网络使用VisualVet系统解决的实际问题
- 解决Mac系统App Store登陆“未知错误”“重试(4)”的问题
- Win10系统在脱机状态下不能使用pin码登陆的详细解决方法
- 使用C#解决部分Win8.1系统窗体每隔几秒失去焦点的问题
- 解决ubuntu 13.04登入系统后触摸板不能使用的问题
- win8.1系统完美解决建行网银和支付宝不能使用的问题。
- Android系统Recovery工作原理之使用update.zip升级过程分析(二)---update.zip差分包问题的解决