Are there any Pitfalls to this approach which I am not seeing
问题 Service Registration services.AddScoped(typeof(PageStorageService<>), typeof(PageStorageService<>)); Service Declaration public interface IStoredPage<T> { T PageState { get; set; } } public class PageStorageService<T> : IStoredPage<T> { public T PageState { get; set; } } Usage in CounterPage @page "/counter" @using BlazorApp1.Data <h1>Counter</h1> <p>Current count: @currentCount</p> @inject PageStorageService<Counter> StorageService <button class="btn btn-primary" @onclick="IncrementCount"