DNN的Link模块使用小技巧

 

这个控件不怎么样但有一个特点很让我难忘,就是不管怎么弄都无法添加相对目录或地址.

为此我看了下源码.

在URLControl.vb中的

Public Property Url() As String 属性中有下面这样的语句

Select Case strCurrentType

Case "U"

If cboUrls.Visible Then

If Not cboUrls.SelectedItem Is Nothing Then

r = cboUrls.SelectedItem.Value

txtUrl.Text = r

End If

Else

Dim mCustomUrl As String = txtUrl.Text

If mCustomUrl.ToLower = "http://" Then

r = ""

Else

r = AddHTTP(mCustomUrl)

End If

End If

再看AddHTTP干了些什么事.

''' -----------------------------------------------------------------------------

''' <summary>

''' Adds HTTP to URL if no other protocol specified

''' </summary>

''' <remarks>

''' </remarks>

''' <param name="strURL">The url</param>

''' <returns>The formatted url</returns>

''' <history>

'''        [cnurse]    12/16/2004    documented

''' [cnurse] 05/06/2005 added chack for mailto: protocol

''' </history>

''' -----------------------------------------------------------------------------

Public Function AddHTTP(ByVal strURL As String) As String

If strURL <> "" Then

If InStr(1, strURL, "mailto:") = 0 And InStr(1, strURL, "://") = 0 And InStr(1, strURL, "~") = 0 And InStr(1, strURL, "\\") = 0 Then

If HttpContext.Current.Request.IsSecureConnection Then

strURL = "https://" & strURL

Else

strURL = "http://" & strURL

End If

End If

End If

Return strURL

End Function

从上面两处我们会发现为什么DNN老是自作多情给我们加http://了.

理论是加 \path\path\与~/path/path都不会加http://

经测试,在Link模块里加只有~/path/path会转化为预期的地址 类似 http://localhost/dotnetnuke/path/path

就是说,它会替换成我们希望的虚拟根目录

原要以为在Tab里也是这样.测试后发现.在Tab里不能达到这样的目的.

posted @ 2007-08-18 01:25  shiningrise  阅读(729)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css