Get CustomerId from Razor

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 11 años
Hi,

I need the CustomerId within the frontend and see there's a cookie Nop.customer available.
Is there also a way to get this id from the framework?

Thanks

Andre
Hace 11 años
_workContext.CurrentCustomer.Id

get a IWorkContext via ctor injection:

IWorkContext workContext
Hace 11 años
Thanks - but maybe you can give me some more help with ...?
For ctor I found this MS thread http://msdn.microsoft.com/en-us/library/ff650802.aspx but I've no idea how to make it work with your solution...
Hace 11 años
in your view you have a WorkContext property, use it like this:

@{
var id = WorkContext.CurrentCustomer.Id ;
}


In other parts of your code, for example a controller, dependency injection can be used:


private IWorkContext _workContext ;

public SomeController( IWorkContext workContext ..... )
{
_workContext = workContext;
}


where SomeController is the constructor
Hace 11 años
Thenks for your support!
Hace 10 años
Thx
Hace 9 años
hello keesjan

as per you say i am try to inject  IWorkContext in WebStoreContext and also StoreService.

but when we run project it give's errors

on ContainerManager.cs(line no 113)

An unhandled exception of type 'System.StackOverflowException' occurred in Autofac.dll


please help me

regards,
jatin
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.