IamMax420
IamMax420
CC#
Created by IamMax420 on 6/26/2024 in #help
Log in system error
I was trying to make a log in system for my web app, but my code doesn't seem to work using AplikacjaWeb.Models; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace AplikacjaWeb.Pages.Registration { public class RegistrationModel : PageModel { private readonly UserManager<UserModel> _userManager; private readonly SignInManager<UserModel> _signInManager; public RegistrationModel(UserManager<UserModel> userManager, SignInManager<UserModel> signInManager) { _userManager = userManager; _signInManager = signInManager; } [BindProperty] public Rejestracja /*Registration in english*/ Input { get; set; } public void OnGet() { } public async Task<IActionResult> OnPostAsync() { if (ModelState.IsValid) { var user = new UserModel { UserName = Input.Username, Email = Input.Email, PasswordHash = Input.Password }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, isPersistent: false); return RedirectToPage("/Index"); } else { Console.WriteLine("Error"); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } return RedirectToPage("/Index"); } } }
13 replies
CC#
Created by IamMax420 on 6/6/2024 in #help
object ref not set blah blah blah
atp i have no Idea what I did wrong. In the following function: public async Task<IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return Page(); } var result = await _signInManager.PasswordSignInAsync(Input1.Username, Input1.Password, false, false); if (result.Succeeded) { return RedirectToPage("/Index"); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return Page(); } } the PasswordManagerAsync() method is throwing the aforementioned exception
3 replies
CC#
Created by IamMax420 on 5/25/2024 in #help
Problem with creating a project
No description
3 replies
CC#
Created by IamMax420 on 5/22/2024 in #help
I'm getting an error "object reference not set to an instance of an object"
the code: @model IEnumerable<WebApp.Models.Produkt> <h1>a List</h1> @if (Model == null || !Model.Any()) { <p>No products available.</p> } else { @foreach (var product in Model) { if (product != null) { <li> <b>@product.name</b> - @product.category <a href="@Url.Action("Details", "Warehouse", new { id = product.id })">Details</a> <button>Delete</button> </li> } } } It appears that Model is null but I don't know how to fix it
13 replies
CC#
Created by IamMax420 on 5/8/2024 in #help
what does assembly mean c#-wise ?
basically the question
7 replies
CC#
Created by IamMax420 on 5/7/2024 in #help
✅ why is the random number not being printed to the console?
No description
58 replies
CC#
Created by IamMax420 on 5/7/2024 in #help
why is there "string[] args" inside the main function parentheses?
Hello, I've just started learning c# (after doing some c++) and I wonder why it's like that since we don't even use it inside the main function, like it's just there and I'd like to know why
11 replies