【原创】如何编写c#用户登陆后用户名在前台显示

这种肯定是判断session啦!!!!!

@{
string username = (string)Session["username"];
user user = new user();
if (username != null && username.Length > 0)
{
user = (user)Session["user"];
}
}

  在页面中就这样写

   @{

    int isLogin = 0;
if (username != null && username.Length > 0)
{
isLogin = 1; if (user.type == 1)
{
<span class="gr-title"><b></b>@username</span>
<div class="sidemenu">
<a href="/Fastorders/myFastorderList?userID=@user.id" class="">我的订单</a>
<a href="/user/logout">退出当前帐号</a>
</div>
}
else
{
<span class="gs-title"><b></b>@username</span>
<div class="sidemenu">
<a href="/Fastorders/myFastorderList?userID=@user.id" class="">单位订单</a>
<a href="/user/logout">退出当前帐号</a>
</div>
}
}
else
{
<span style="padding-left: 30px;background: url(/images/index/index-login.png) no-repeat 5px center;"></span>
<a href="/user/login" style="margin-right:15px;">登录</a><a href="/user/register">注册</a>
}
}

  

上一篇:图片url转base64


下一篇:【转】Android ClearEditText:输入用户名、密码错误时整体删除及输入为空时候晃动提示