在MVC框架中传递数据 [英] passing data in MVC framework
本文介绍了在MVC框架中传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是MVC框架的新手。
我正在处理一个应用程序。
我有一个控制器类,我在会话中存储了一个值。
现在我想在其他模型类上检索会话值以作为参数传递给sql查询。
请帮助
在你的一个控制器中感谢
I am new to MVC framework.
I am working one application.
I have an one controller class in that i have stored one value in session .
now i want to retrive session value on other model class to pass as parameter to sql query.
Pls help
Thanks
推荐答案
方法做一个
in one of your controller methods do a
var myval = HttpContext.Current.Session["MyValue"];
["MyValue"] // is the key of the item you want to use.
然后将此myval对象传递给您要使用它的类。
then pass this myval object to the class which you want to use it in.
这篇关于在MVC框架中传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文