Another method you might consider is an old-school meta update
<meta http-equiv="refresh" content="4; url=http://example.com/">
What can you control using the property on your model or the value in the ViewBag
@if(Model.DoRedirect) { <meta http-equiv="refresh" content="4; url=http://example.com/"> }
Since this should be in the header, you may need to place the header section in your _layout
<head> ... @RenderSection("header", required: false) </head>
What you can use in your view, for example
@section header @if(Model.DoRedirect) { <meta http-equiv="refresh" content="4; url=http://example.com/"> } }
source share