java脚本中的Response.Redirect("〜/ abc.aspx")的等效代码是什么?

Fre*_*Boy 2 javascript asp.net

什么是Response.Redirect(~/Account/Login.aspx");javascript中的等效代码?

我试过了:window.location="~/Account/Login.aspx"~javascript不接受.那么,替代代码是什么?

注意:javascript脚本是在方法的服务器端Page_Load使用ClientScript.RegisterClientScriptBlock.

Ale*_*cka 13

使用

window.location='<%= ResolveUrl("~/Account/Login.aspx") %>'
Run Code Online (Sandbox Code Playgroud)

编辑:如果它是在codebehind中创建的,那么使用

string.Format("window.location='{0}';", ResolveUrl("~/Account/Login.aspx"))
Run Code Online (Sandbox Code Playgroud)