开发者

ASP.NET MVC refresh header issue

开发者 https://www.devze.com 2023-02-15 00:11 出处:网络
I want to call an action method (DownloadPictures) after i redirect to a different page, so i use the refresh header

I want to call an action method (DownloadPictures) after i redirect to a different page, so i use the refresh header

UrlHelper url = new UrlHelper(Request.RequestContext);
Response.AddHeader("REFRESH" , "1;URL=" + url.Action("DownloadPictures" , "Cart" , new { isFree = true }));
return Redirect(returnUrl != null ? returnUrl : url.Action("Index", "Home"));

And my Download Pictures method looks like this with a breakpoint set on the first line, but this method never gets called

public ActionResult DownloadPictures ( bool? isFree ) {
    Cart cart = (Cart)HttpContext.Session["_cart"];
    ....
    //The Download Picture Method returns a File (a zip file)
}
开发者_Go百科

Any help would be appreciated. Thanks


Most browsers ignore the refresh header

Use another method like javascript etc

e.g.

<html>
<head>
<script type="text/javascript">
  function delayRedirect()
  {
    window.location = "/DownloadPictures";
  }
</script>
</head>
<body onLoad="setTimeout('delayRedirect()', 1000)">
...
</body>
</html> 
0

精彩评论

暂无评论...
验证码 换一张
取 消