2009-08-07 15 views

答えて

3

ログインURLを取得するユーティリティメソッドです:

C#

 /// <summary> 
     /// Gets the login URL for the given portal from the current <paramref name="request"/>. 
     /// </summary> 
     /// <param name="portalSettings">The portal settings.</param> 
     /// <param name="request">The request.</param> 
     /// <returns>The URL for the login page</returns> 
     /// <exception cref="ArgumentNullException">if <paramref name="portalSettings"/> or <paramref name="request"/> is null.</exception> 
     public static string GetLoginUrl(PortalSettings portalSettings, HttpRequest request) 
     { 
      if (portalSettings != null && request != null) 
      { 
       int tabId = portalSettings.ActiveTab.TabID; 
       string controlKey = "Login"; 
       string returnUrl = request.RawUrl; 
       if (returnUrl.IndexOf("?returnurl=", StringComparison.OrdinalIgnoreCase) > -1) 
       { 
        returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl=", StringComparison.OrdinalIgnoreCase)); 
       } 

       returnUrl = HttpUtility.UrlEncode(returnUrl); 

       if (!Null.IsNull(portalSettings.LoginTabId) && string.IsNullOrEmpty(request.QueryString["override"])) 
       { 
        // user defined tab 
        controlKey = string.Empty; 
        tabId = portalSettings.LoginTabId; 
       } 
       else if (!Null.IsNull(portalSettings.HomeTabId)) 
       { 
        // portal tab 
        tabId = portalSettings.HomeTabId; 
       } 

       // else current tab 
       return Globals.NavigateURL(tabId, controlKey, new string[] { "returnUrl=" + returnUrl }); 
      } 

      throw new ArgumentNullException(portalSettings == null ? "portalSettings" : "request"); 
     } 

VB.NET

''' <summary> 
''' Gets the login URL for the given portal from the current <paramref name="request"/>. 
''' </summary> 
''' <param name="portalSettings">The portal settings.</param> 
''' <param name="request">The request.</param> 
''' <returns>The URL for the login page</returns> 
''' <exception cref="ArgumentNullException">if <paramref name="portalSettings"/> or <paramref name="request"/> is null.</exception> 
Public Shared Function GetLoginUrl(portalSettings As PortalSettings, request As HttpRequest) As String 
    If portalSettings <> Nothing AndAlso request <> Nothing Then 
     Dim tabId As Integer = portalSettings.ActiveTab.TabID 
     Dim controlKey As String = "Login" 
     Dim returnUrl As String = request.RawUrl 
     If returnUrl.IndexOf("?returnurl=", StringComparison.OrdinalIgnoreCase) > -1 Then 
      returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl=", StringComparison.OrdinalIgnoreCase)) 
     End If 

     returnUrl = HttpUtility.UrlEncode(returnUrl) 

     If Not Null.IsNull(portalSettings.LoginTabId) AndAlso String.IsNullOrEmpty(request.QueryString("override")) Then 
      ' user defined tab 
      controlKey = String.Empty 
      tabId = portalSettings.LoginTabId 
     ElseIf Not Null.IsNull(portalSettings.HomeTabId) Then 
      ' portal tab 
      tabId = portalSettings.HomeTabId 
     End If 

     ' else current tab 
     Return Globals.NavigateURL(tabId, controlKey, New String() {"returnUrl=" + returnUrl}) 
    End If 

    Throw New ArgumentNullException(If(portalSettings = Nothing, "portalSettings", "request")) 
End Function 
0

あなたも、デフォルトのURL場合は、デフォルトDNNのログインページに到達するために、CTL =ログインクエリ文字列を渡すことができますか?

string loginURL = string.Format("{0}://{1}/Default.aspx?ctl=login", 
    Request.Url.Scheme, Request.Url.Host); 
Response.Redirect(loginURL); 
3

Globals.LoginURL

...変更されました
public static string LoginURL(
    string returnURL, 
    bool override 
) 
+0

returnURLにクエリ文字列params(基本的に?を含む)がある場合、このメソッドは現在のページを返します。 DNN 6&7で再現可能です。 – Valentin

+0

実際にはログインアドレスは問題ありません。クエリ文字列paramsを持つと、ログイン後のリダイレクトが機能しません。 – Valentin

関連する問題