使用webservice解决多系统登陆问题
来源:互联网 发布:超星尔雅网络课程手机 编辑:程序博客网 时间:2024/05/16 09:04
首先新建一个空项目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解决多系统登陆问题(收藏)
- 解决多登陆的问题
- 如何解决Xmanager不能登陆Linux系统问题
- 解决登陆问题
- webService 问题不能解决
- 登陆EBS系统问题
- 解决使用HttpWebRequest时总是提示登陆超时的问题
- 使用sessionStorage解决刷新后自动定点登陆的问题
- 解决kubuntu 无法登陆问题
- cvs 登陆问题的解决
- 解决登陆 cuteFTP 的问题
- webservice重载问题的解决
- 机房收费系统登陆问题
- 解决Win2000Sever登录时“不支持网络请求,系统无法让您登陆”问题
- .net开源小范例(常用)
- MYSQL的master/slave数据同步配置
- Web Service安全机制探讨
- Unicode是什么?
- Webservice 的设计和模式
- 使用webservice解决多系统登陆问题
- 动态创建DataGrid的模版列
- 在asp.net中为Web用户控件添加属性和事件
- 唯一缺的是SB用户(ZT)
- SOA概览
- 加密web.config中的信息
- 程序员,建立你的商业意识
- 正确分区,使1.99G变成2G整数
- 我对属性的简单理解(C#)