这是给我站点根路径的属性
public static string SiteRootPath
{
get
{
string host = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
string appRootUrl = HttpContext.Current.Request.ApplicationPath;
if (string.IsNullOrEmpty(appRootUrl) || appRootUrl == "/")
{
return host + "/";
}
else
{
return host + appRootUrl + "/";
}
}
}
我喜欢这个
string path = EMS.DAL.DALHelper.SiteRootPath + "Home.aspx";
然后我这样做
string script = "<script language='javascript' >alert('User registered successfully');window.location.replace('" + path + "');</script>";
Page.RegisterStartupScript("alert", script);
这会将我重定向到主页,并且在 localhost 上运行良好,但在发布站点的 IIS 上却不行。
当我检查页面源时,仅发现“警报('用户注册成功');” 里面的脚本标签??
没办法解决。
有任何想法吗 ??