The documentation [http://aspnetboilerplate.com/Pages/Documents/Abp-Session]) says I can implement my own AbpSession but it doesn't say how to register it.
As a side note, I need to retrieve the authenticated user id which is in a cookie. Is the session the right place to do this?
I implemented it like this
public class AbpSession : IAbpSession
{
public Abp.MultiTenancy.MultiTenancySides MultiTenancySide
{
get { return Abp.MultiTenancy.MultiTenancySides.Host; }
}
public int? TenantId
{
get { return 1; }
}
public long? UserId
{
get
{
return 12345; // TODO how to get this from cookie!
}
}
}
but now when I inject IAbpSession in an ApplicationService, an error is thrown; part of which is pasted below.
"innerException":{"message":"An error has occurred.","exceptionMessage":"Can't create component 'Scorecard.UserDomain.UserApplicationService' as it has dependencies to be satisfied.\r\n\r\n'Scorecard.UserDomain.UserApplicationService' is waiting for the following dependencies:\r\n- Service <span style="color:#FF0080">'Abp.Runtime.Session.IAbpSession' which was not registered</span>.\r\n",
1 Answer(s)
-
0
Hi,
Registering AbpSession as same as registering another component, not special. See documents: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection#DocRegisterDependencies">http://www.aspnetboilerplate.com/Pages/ ... pendencies</a> Easiest way is to simply implementing ITransientDependency interface.
For other questions, use this topic: #138.