English 中文(简体)
是否有任何网页上的具体财产取代会议[“用户_id”]
原标题:Is there any page specific property to replace session["user_id"]
  • 时间:2010-11-27 11:14:51
  •  标签:
  • asp.net

我的网页一使用了Session[“用户_id”],以了解用户的地位。 是否有任何特定财产可替换<代码>[“用户_id”]。

最佳回答


You can wrap user id keeping using next extension method:

至<代码> 之后:

public static string UserId (this IPrincipal user)
{
    get
    {
        return HttpContext.Current.State["user_id"];
    }
    set
    {
        HttpContext.Current.State["user_id"] = value;
    }
}

使用(在网页上);

this.Request.User.UserId; // get, set
问题回答

您可以使用电梯来储存用户,而不是会议,将其从网页上移至网页。

另一种选择是使用电灯,但每页限量有限,不上其他页面。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签