Base solution for your next web application
Open Closed

Best approach to use abp.session.userId in mpa application #1252


User avatar
0
dermeister created

Hey,

There's an easy solution for using current userId in spa applications but what is the way of using logined userId in cshtml mp application.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team
    1. Open your view base (it's something like that: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebMpa/Views/AbpProjectNameWebViewPageBase.cs">https://github.com/aspnetboilerplate/mo ... ageBase.cs</a>).

    2. Add a property like that:

    public IAbpSession AbpSession { get; private set; }

    1. Set it in your constructor:

    AbpSession = IocManager.Instance.Resolve<IAbpSession>();

    1. In your cshtml files, just use AbpSession.UserId

    Have a nice day.