DuendeSoftware / Samples

Samples for our Products
Other
227 stars 269 forks source link

QuickStart 2 Error #57

Closed dajma00 closed 2 years ago

dajma00 commented 2 years ago

In QuickStart 2, after running this command:

dotnet new isui

In file

\quickstart\src\IdentityServer\Pages\ServerSideSessions\Index.cshtml.cs

I get the following error:

The type or namespace name  ISessionManagementService could not be found.
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace IdentityServer.Pages.ServerSideSessions
{
    public class IndexModel : PageModel
    {
        private readonly ISessionManagementService _sessionManagementService;

        public IndexModel(ISessionManagementService sessionManagementService = null)
        {
            _sessionManagementService = sessionManagementService;
        }

        public QueryResult<UserSession> UserSessions { get; set; }

        [BindProperty(SupportsGet = true)]
        public string Filter { get; set; }

        [BindProperty(SupportsGet = true)]
        public string Token { get; set; }

        [BindProperty(SupportsGet = true)]
        public string Prev { get; set; }

        public async Task OnGet()
        {
            if (_sessionManagementService != null)
            {
                UserSessions = await _sessionManagementService.QuerySessionsAsync(new SessionQuery
                {
                    ResultsToken = Token,
                    RequestPriorResults = Prev == "true",
                    DisplayName = Filter,
                    SessionId = Filter,
                    SubjectId = Filter,
                });
            }
        }

        [BindProperty]
        public string SessionId { get; set; }

        public async Task<IActionResult> OnPost()
        {
            await _sessionManagementService.RemoveSessionsAsync(new RemoveSessionsContext { 
                SessionId = SessionId,
            });
            return RedirectToPage("/ServerSideSessions/Index", new { Token, Filter, Prev });
        }
    }
}
brockallen commented 2 years ago

I don't follow -- that service is in the Duende.IdentityServer.Services namespace. Perhaps you're not referencing IdentityServer v6.1.0? I bet this is the issue -- you're using the QS that uses IdentityServer 6.0, but your template is 6.1.0.

brockallen commented 2 years ago

I'm assuming what I said above was the issue, so I'll close this. If not, let us know.