开发者

ASP.NET MVC refresh header issue

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜