有没有办法在wpf中使用像asp net这样的会话 [英] is there any way using session like asp net in wpf

查看:49
本文介绍了有没有办法在wpf中使用像asp net这样的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在wpf中使用类似asp net的会话。并且使用单例设计模式进行会话类时是好的。是否有意义?



i需要这个因为;

当用户登录时我必须知道每个窗口中的用户ID

is there any way using session like asp net in wpf. AND is it good when make session class , using singleton design pattern. is it sense?

i need this becouse;
when user log in i have to know user id in every window

推荐答案

否。

为什么在永久托管的应用程序中需要一些在会话中保留数据的方法?



会话用于保存特定于客户端的信息,而无需保存页面及其所有上下文。这是必需的,因为一旦将页面HTML发送到浏览器,就可以关闭应用程序,并且会话保留回发后可能需要的信息。对于WPF应用程序来说情况并非如此 - 它的完整上下文在应用程序关闭之前仍然是实时 - 并且它没有回发!
No.
Why would you need some method of preserving data across a session on a permanently hosted application?

The Session is there to preserve information specific to a client, without having to save the page and all it's context. It's needed because once the page HTML has been sent to the browser, the application can be closed, and the Session preserves information which may be needed on a post back. That isn't the case with a WPF app - it and it's full context remains "live" until the application is closed - and it doesn't have post backs!


Web应用程序中的会话存储客户端状态(许多客户端),在WPF应用程序中只有1个客户端。



是的,你可以创建一个会话对象来存储数据在[数据库是一样的]。



根据你想要做的事情,它可能是一个单身。
Sessions in Web applications store the client side state (lots of clients), in a WPF application you only have 1 client.

Yes, you can create a "session" object to store data in [a database is the same thing].

Depending on what you want to do it may be a singleton.


这篇关于有没有办法在wpf中使用像asp net这样的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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