Reputation: 7605
I want to redirect the user if the date is past 5/25/2020 otherwise they get the current view
public ActionResult Login()
{
DateTime dt = DateTime.Now;
DateTime expirationDate = new DateTime(2020, 05, 25);
if (dt > expirationDate)
{
return RedirectToAction("ThankYou", "Home");
}
else
{
}
return View();
}
Code from HomeController.cs
public IActionResult Index()
{
var userId = User.Identity.Name;
string userIdfromCache = SaveToCache("UserID", userId);
return RedirectToAction("Login", "Authentication");
}
public IActionResult ThankYou()
{
return View();
}
The IActionResult ThankYou() is not redirecting the user. It should display a static HTML file
Upvotes: 0
Views: 46
Reputation: 75
I guess your problem is somewhere else, I tried your code it works just fine!
Upvotes: 0
Reputation: 255
The only return in the ActionResult is the View(). Replace RedirectToAction("ThankYou", "Home");
with return RedirectToAction("ThankYou", "Home");
and it should work
Upvotes: 1