1

我有我的 mvc 网页的布局页面,在那里我做了类似的事情。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
</head>
<body>
<div class="page">
<div id="header">
<div>
   @{
            SessionDetail sess = new SessionDetail();
            ICacheProvider cache = (ICacheProvider)DIConfig.GetInstance("cacheprovider");
            sess = (SessionDetail)cache.Get(Session["usersession"].ToString());
           }      
             <div id="menu" align="right">
            <li class="first" style="list-style-type: none;">Welcome <b>**@sess.DisplayName**</b>! |@Html.ActionLink("Logout","Logout","Account")</li>
            </div>
            <div class="site-title">
                <h2>Dheutto</h2>
            </div>
        </div>
       <div align="right">@Html.ActionLink("Show Devices","Index","Device")</div>
      </div>      
</body>
</html>

现在从这里我在 sess 对象中有会话详细信息。我是否可以将 sess 对象中的值传递到在此布局页面下呈现的所有视图页面?

4

0 回答 0