IamMax420
Log in system error
more specifically, when I hit the "submit" button, console prints out "error", which is what I did here
if (result.Succeeded)
{
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToPage("/Index");
}
else
{
Console.WriteLine("Error");
}
13 replies
object ref not set blah blah blah
here's the cshtml file btw @page
@model AplikacjaWeb.Pages.Logowanie.LogowanieModel
@{
}
<h1 class="Logowanie">Logowanie</h1>
<div class="container border" style="padding:20px;">
<form method="post" style="margin-left:400px;">
<div class="text-danger" asp-validation-summary="ModelOnly"></div>
<div class="form-group row div1">
<div class="col-3 column1">
<label asp-for="Input1.Username">Username:</label>
</div>
<div class="col-2">
<input type="text" asp-for="Input1.Username" class="form-control" style="margin-left:-110px; margin-top:-10px; width:250px;" />
</div>
<span class="text-danger" asp-validation-for="Input1.Username"></span>
@*ten span sprawia że gdy user nie wprowadzi danych do pola to zostanie wyswietlona wiadomosc z atrybutu required*@
</div>
<div class="form-group row div2">
<div class="col-3 column2">
<label asp-for="Input1.Password">Password:</label>
</div>
<div class="col-2">
<input type="password" asp-for="Input1.Password" class="form-control" style="margin-left:-110px; margin-top:-10px; width:250px;" />
</div>
<span class="text-danger" asp-validation-for="Input1.Password"></span>
</div>
<div>
<button type="submit" class="przycisk1">Zaloguj</button>
</div>
</form>
</div>
3 replies
I'm getting an error "object reference not set to an instance of an object"
these two: [HttpGet]
[HttpGet]
public IActionResult List1()
{
var products = _warehouseService.GetAllProdukts();
return View();
}
[HttpGet]
public IActionResult Details(int id)
{
var product = _warehouseService.Get(id);
return View();
}
13 replies
I'm getting an error "object reference not set to an instance of an object"
here's the code:
using Microsoft.AspNetCore.Mvc;
using WebApp.Models;
using WebApp.Services.Interfaces;
namespace WebApp.Controllers
{
public class WarehouseController : Controller
{
private readonly IWarehouseService _warehouseService;
public WarehouseController(IWarehouseService warehouseService)
{
_warehouseService = warehouseService;
}
public IActionResult Index()
{
return View();
}
[HttpGet]
public IActionResult Add()
{
return View();
}
[HttpPost]
public IActionResult Add(Produkt body)
{
if(!ModelState.IsValid)
{
return View(body);
}
//logika do zapisu produktu
var id = _warehouseService.Save(body);
ViewData["ProductId"] = id;
TempData["ProductId"] = id;
return RedirectToAction("List1");
}
[HttpGet]
public IActionResult List1()
{
var products = _warehouseService.GetAllProdukts();
return View();
}
[HttpGet]
public IActionResult Details(int id)
{
var product = _warehouseService.Get(id);
return View();
}
[HttpDelete]
public IActionResult Delete(int id)
{
_warehouseService.Delete(id);
return RedirectToAction("List1");
}
}
}
13 replies