.
why is my handler not working, also the breakpoint doesn't even get hit for it
[ValidateAntiForgeryToken]
public IActionResult OnPostPlaceOrder()
{
try
{
if (!_userManager.UserIsGuest())
{
int? customerID = _customerManager.GetCustomerId();
if (customerID.HasValue)
{
var rentalOrder = new RentalOrder
{
CustomerID = customerID.Value,
RentalStartDate = DateTime.Now,
RentalEndDate = DateTime.Now.AddDays(7),
TotalCost = _rentalOrderManager.CalculateTotalCost(Cart),
Status = OrderStatus.Pending,
StartTime = TimeSpan.FromHours(8),
EndTime = TimeSpan.FromHours(18)
};
int orderId = _rentalOrderManager.PlaceOrder(Cart, rentalOrder);
return RedirectToPage("/OrderConfirmation", new { orderId });
}
}
return Page(); } catch (Exception ex) { _logger.LogError(ex, "An error occurred in OnPostPlaceOrder method"); return RedirectToPage("/Error"); } } public IActionResult OnPostRemoveFromCart(int ItemID) { _cartManager.RemoveItemFromCart(Cart, ItemID); return RedirectToPage("/Cart"); } } } ----------------------- <form method="post" asp-page-handler="PlaceOrder"> <button type="submit" class="btn btn-primary">Place Order</button> </form>
return Page(); } catch (Exception ex) { _logger.LogError(ex, "An error occurred in OnPostPlaceOrder method"); return RedirectToPage("/Error"); } } public IActionResult OnPostRemoveFromCart(int ItemID) { _cartManager.RemoveItemFromCart(Cart, ItemID); return RedirectToPage("/Cart"); } } } ----------------------- <form method="post" asp-page-handler="PlaceOrder"> <button type="submit" class="btn btn-primary">Place Order</button> </form>
7 replies