zoukankan
html css js c++ java
在asp.net页面中动态调用方法
系统原来是通过webservice实现的,现在需要在webservice访问cookie, 但在webservice中没法调用cookie,后来发现可以通过下列方法实现:具体例子如下 :
protected
void
Page_Load(
object
sender, EventArgs e)
{
//
参数定义
object
[] args
=
new
object
[]
{}
;
Type type
=
this
.GetType();
//
动态调用方法,方法名可以通过参数传过来
MethodInfo methodInfo
=
type.GetMethod(
"
Test
"
);
if
(methodInfo
!=
null
)
{
args
=
new
object
[methodInfo.GetParameters().Length];
//
对方法名的参数进行赋值
for
(
int
i
=
0
; i
<
methodInfo.GetParameters().Length; i
++
)
{
ParameterInfo param
=
methodInfo.GetParameters()[i];
args[i]
=
Request.QueryString[param.Name];
}
//
执行方法
methodInfo.Invoke(
this
, args);
}
}
public
void
Test(
string
Id,
string
name)
{
//
Response.Write(Request.Cookies[0].Value);
Response.Write(Id
+
"
:
"
+
name);
}
public
void
TestA()
{
Response.Write(
"
dddd
"
);
}
查看全文
相关阅读:
ETCD 添加节点报错 tocommit(2314438) is out of range [lastIndex(0)]. Was the raft log corrupted, truncated, or lost?
如何删除docker镜像中已配置的volume
kubeadm初始化集群
kubeadm安装依赖镜像
standard_init_linux.go:178: exec user process caused "no such file or directory"
kubernetes支持local volume
git http方式时保存密码
分布式核心技术
docker使用
Python实用日期时间处理方法汇总
原文地址:https://www.cnblogs.com/mini/p/891797.html
最新文章
LJ2268W驱动链接
开源录屏软件Capture推荐
[转]解决 gem install 安装失败
让typecho支持PHP7
ubuntu修改apache端口号
[转]Ubuntu18.04隐藏顶栏与侧栏
使用tuna源安装docker-ce
[转]How to Install Oracle Java 11 in Ubuntu 18.04/18.10
[转]Gnome桌面的录屏插件easyscreencast
[转]10 Best GTK Themes for Ubuntu 18.04
热门文章
[转]Ubuntu18.04 主题美化以及常用软件
[转]casperjs截图出现黑色背景
[转]Nodejs利用phantom 将html生成图片
[转]Mathjax语法总结
[转]java 根据模板文件生成word文档
“与”运算是什么意思
k8s获取用户BearerToken方式
k8s容器IO使用率排查说明
基础知识
LR编写grammar中的问题和解决方法
Copyright © 2011-2022 走看看