0

このscriptmanagerをaspxページで使用しました。

ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Registered Successfully !!'); window.location='" + Request.ApplicationPath + "/admin/CreateSubAdmin.aspx';", true);

正しく機能しているよりもローカルサーバーで使用している場合。およびurlは次のようになります:host url:xyz.aspx / admin / CreateSubAdmin.aspx

下線セクションは管理セクションにあります。

しかし、サーバーではこれは正しく機能していません。次のようになります:/admin/CreateSubAdmin.aspxのみ。

しかし、私はそれをwww.xyz.com/admin/CreateSubAdmin.aspxのように表示したいと思います。

だから私が間違って書いたもの。plzは私を助けます。

前もって感謝します..

4

2 に答える 2

0

次のようなヘルパー関数を使用します。

public static string GetApplicationRoot()
{
    string host = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
    string applicationPath = HttpContext.Current.Request.ApplicationPath;
    if (applicationPath == "/")
    {
        return host;
    }
    else
    {
        return host + applicationPath;
    }
}
于 2012-06-22T11:58:28.483 に答える
0

ApplicationPathを削除するか、最初のスラッシュを削除するだけです。

ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit",
 "alert('Registered Successfully !!'); window.location='" + Request.ApplicationPath + "admin/CreateSubAdmin.aspx';", true);

また

ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", 
 "alert('Registered Successfully !!'); window.location='/admin/CreateSubAdmin.aspx';", true);

ここでの問題は、ケースで機能する完全な URL を作成する方法です。

"http:" + Request.Url.Host別の方法として、完全な URL を取得するために を使用してビルドすることもできます。

于 2012-06-22T11:48:47.223 に答える