我正在開發一個ASP.Net MVC 5項目。我提交內容時需要重定向頁面。我用這個Javascript代碼:JavaScript重定向到控制器動作asp.net mvc
return Content("<script language='javascript' type='text/javascript'>alert('Edited...');window.location.href = 'ShowColor';</script>");
當我編輯
http://localhost:56583/Admin/EditColor/27
東西,我想重定向我的網頁
http://localhost:56583/Admin/ShowColor
用它去
上面的代碼http://localhost:56583/Admin/EditColor/ShowColor
而且我用下面的代碼根據Redirecting to action from javascript,但它並沒有太多的工作:
return Content("<script language='javascript' type='text/javascript'>alert('Edited...');window.location.href = '@Url.Action('ShowColor', 'Admin')';</script>");
我不知道如何解決它。感謝您的任何幫助
爲什麼不只是'返回RedirectToAction(「ShowColor」,「管理員」);'? –
因爲我也想顯示提醒@StephenMuecke –