如何将.aspx.cs页面中的数据传递/传递到.svc.cs文件 [英] How to session/pass data from .aspx.cs page to .svc.cs file

查看:111
本文介绍了如何将.aspx.cs页面中的数据传递/传递到.svc.cs文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Again,



我在asp.net网络应用程序中使用Service1.svc服务。

我关心的是我可以将login.aspx.cs中的用户名转换为此.svc文件,同时我还想将页面名称(login.aspx.cs)转发到服务文件。



我试过跟随会话用户名:

Hello Again,

I am using a service Service1.svc in an asp.net web application.
My concern is how can I session username from login.aspx.cs to this .svc file and at the same time I also want to session the page name(login.aspx.cs) to service file.

I have tried following to session username:

string uname=HttpContext.Current.Session["user"].ToString();



但它表示没有创建对象。



毫无疑问,我可以在一个网络应用程序中拥有多少服务?



如何我可以实现吗?



任何帮助或提示都可以。 :-)



我尝试了什么:



我试过了跟随会话用户名:


But it says object is not created.

And as a doubt, how many services can I have in a single web application?

How can I achieve this?

Any help or hint will do. :-)

What I have tried:

I have tried following to session username:

string uname=HttpContext.Current.Session["user"].ToString();



但它说对象没有创建。


But it says object is not created.

推荐答案

首先,恕我直言,使用ASP.NET托管的WCF服务不是一个好主意,但你最好选择ASMX ...

但是如果您选择坚持使用WCF并且希望它与ASP.NET合作,则必须注意以下几点:

1.使用HTTP绑定(也是)

2.调整WCF服务的ASP.NET兼容性

详细信息如下:

WCF服务和ASP.NET [ ^ ]

在ASP.NET中托管WCF服务–生存指南| leastprivilege.com [ ^ ]
First of all, IMHO it is not a good idea to use ASP.NET hosted WCF services, but you better choose ASMX...
However if you choose to stick with WCF and you want it cooperate with ASP.NET, you have to take care a few things:
1. Use HTTP binding (too)
2. Adjust ASP.NET compatibility of the WCF service
The details are here:
WCF Services and ASP.NET[^]
Hosting WCF Services in ASP.NET – The Survival Guide | leastprivilege.com[^]


这篇关于如何将.aspx.cs页面中的数据传递/传递到.svc.cs文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆