MVC redirect to another page after a four second pause

asp.net, asp.net-mvc, asp.net-mvc-4, javascript, razor

Solution

You wont be able to do that on the server side, you'll have to use javascript. You can use

window.setTimeout(function(){
window.location.href='your URL';
}, 4000);

Problem

I'm relatively new to MVC, but I have a problem: Currently, when a user signs into our site for the first time, they are redirected to a change password page; they must change their password before they can access any of the main functionality of the site. After they change their password successfully though, I want to show my custom "Password successfully changed" message on the change password page; I currently do this. After I display my custom message on my change password page, I want to wait a few seconds and then redirect them to the home page. I want to be able to do something like this: ``` //User successfully changes password on ChangePassword page return View(); //This keeps them on the ChangePassword page and shows the success message //Wait five seconds on ChangePassword page //Redirecttoaction("Index", "Home"); ``` Thanks!

Original source

Related problems