2012-10-27 16 views
0

我有一個行動tresult方法,並在其中我想要在新窗口或新標籤頁中打開一個網址,我該如何處理它?如何打開瀏覽器的行動結果?

在我的代碼

它的作品不是我的意思是重定向到會員帳戶,不開我的網址

public ActionResult myactionresult() 
    { 
     Response.Write("<script language=\"javascript\">"); 
     Response.Write("window.open('" + "http://www.xxx.com" + ,'_blank')"); 
     Response.Write("</script>"); 

     return RedirectToAction("Index", "MembersAccount"); 
     } 

回答

0

試試這個:

控制器

public ActionResult myactionresult() 
{ 
    String jScript = String.Empty; 
    jScript = "<script language=\"javascript\">"; 
    jScript += "window.open('http://www.xxx.com' ,'_blank')"; 
    jScript += "</script>"; 

    ViewBag.jScript = jScript; 

    return RedirectToAction("Index", "MembersAccount"); 
} 

查看:任何地方在視圖的身體

@ViewBag.jScript 

這將解決您的問題;

+0

我的重定向必須發生在行動導致你的情況下任何重定向將發生 – motevalizadeh

+0

@motevallizadeh,你想通過actionresult打開另一個窗口,並不想打開該perticular動作? –

+0

@ Kundan Singh Chouhan,是的,我打開它後,它最後一行重定向到我的行動 – motevalizadeh

相關問題