Ich umleite von dort von einer anderen Anwendung in meine .NET 8 -Anwendung um. Ich erhalte die BenutzerID und fülle das Gleiche in meiner Sitzung. Ich füge die BenutzerID in Ansprüchen hinzu.
Ich umleite von dort von einer anderen Anwendung in meine .NET 8 -Anwendung um. Ich erhalte die BenutzerID und fülle das Gleiche in meiner Sitzung. Ich füge die BenutzerID in Ansprüchen hinzu.[code]using CCP_Core.Service; using Core.Service; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Diagnostics; using Microsoft.EntityFrameworkCore; using Microsoft.Office.Interop.Excel;
var connectionString = builder.Configuration.GetConnectionString("connection");
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Home/UnAuthorized"; // Set your login path here });
builder.Services.AddScoped(provider => new DataService(connectionString)); builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); builder.Services.AddDistributedMemoryCache(); builder.Services.AddExceptionHandler();
app.MapRazorPages(); app.Run(); [/code] Dies ist der Homecontroller Code: [code]using System.Data; using System.Security.Claims; using System.Security.Principal; using System.Text; using CCP_Core.Model; using CCP_Core.Service; using Core.Model; using Core.Service; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis.CSharp.Syntax; using OfficeOpenXml;
namespace Core.Controllers { [Authorize] public class HomeController : Controller { private readonly DataService _dataService; private readonly IWebHostEnvironment _environment;
Ich umleite von dort von einer anderen Anwendung in meine .NET 8 -Anwendung um. Ich erhalte die BenutzerID und fülle das Gleiche in meiner Sitzung. Ich füge die BenutzerID in Ansprüchen hinzu. using...