最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
WebService几种 限制用户访问的方法
时间:2022-06-25 05:47:07 编辑:袖梨 来源:一聚教程网
webservice几种 限制用户访问的方法
1.集成windows验证
2.soap头验证信息
创建一个类集成soapheader,里面属性存放验证信息(用户名,密码等),此字段必须设为公共(public)的.
1 public class soapusernameandpassword:soapheader2 {3 public string username;4 public string password;5 }
在webservice程序中加入该类实例.
public soapusernameandpassword suap = new soapusernameandpassword();
给带验证的方法加入soapheader属性标签.
代码
1 [webmethod]2 [system.web.services.protocols.soapheader("suap",direction=soapheaderdirection.inout,required=true)]3 public string helloworld() {4 if (suap.username == "admin" && suap.password == "admin")5 {6 return "hello world";7 }8 else return "please try a valid user";9 }
相关文章
- 街漓芳传安全驾驶成就达成方法 10-14
- 华夏绘世录绘院玩法功能介绍说明 10-14
- 原神6.1上半抽卡建议 10-14
- 绝区零2.3上半卡池抽取建议 10-14
- 明日方舟折桠技能介绍一览 10-14
- 明日方舟第16章反常光谱沙盘挂机阵容推荐 10-14