Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /UsersPage/undefined
i have this ajax script which i supposedly redirect the user to the specified url:
$.ajax({
url: '@Url.Action("UsersHome", "UsersPage")',
type: 'POST',
data: {
chosenMood: chosenMood
},
success: function(response) {
// Handle the success response
console.log('Success:', response);
// Redirect to the received URL
window.location.href = response.redirectUrl;
},
error: function(xhr, status, error) {
// Handle errors, if any
console.error('Error:', error);
// Optionally, you can display an error message to the user
alert('An error occurred. Please try again later.');
}
});
and this is the controller or the target page:
public ActionResult UsersHome()
{
if (User.Identity.IsAuthenticated)
{
//Session["ChosenMood"] = chosenMood;
var redirectUrl = Url.Action("UsersHome", "UsersPage");
//return Json(new { redirectUrl }, JsonRequestBehavior.AllowGet);
return View();
} else
{
return RedirectToAction("../Home/Index");
}
}