How to get session at PrepareProductOverviewModelsAsync

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 yıl önce
I want to get a created Session in the above function but the usual:

HttpContext.Session.GetString("key");


does not work. So how can I do it ?

Also is this the best approach to pass values here using Sessions or there is something else built-in nopcommerce.
1 yıl önce
See an example of how it's done in
\Libraries\Nop.Services\Authentication\External\ExternalAuthenticationService.cs
protected virtual IActionResult ErrorAuthentication(IEnumerable<string> errors, string returnUrl)
        {
            var session = _httpContextAccessor.HttpContext?.Session;

            if (session != null)
            {
                var existsErrors = session.Get<IList<string>>(NopAuthenticationDefaults.ExternalAuthenticationErrorsSessionKey)?.ToList() ?? new List<string>();
...
1 yıl önce
The other question still remains is this the ONLY way to pass on variables or is there something built-in in nopcommerce.
1 yıl önce
Using Generic Attributes is the typical way it's done.  For example, see

\Presentation\Nop.Web\Controllers\CheckoutController.cs
public virtual async Task<IActionResult> SelectBillingAddress(...
...
await _genericAttributeService.SaveAttributeAsync<ShippingOption>(customer, NopCustomerDefaults.SelectedShippingOptionAttribute, null, store.Id);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.