Handle duplicate parameters in DotNetNuke UrlRewriteModule.

In my application based on DotNetNuke 4.0.2 I've noticed that sometimes I have url with duplicate parameters, e.g "PortalID=0&PortalID=0"

I didn't  fully investigate why it happens and is it DNN core issue or my custom code, but the current UrlRewriteModule code doesn't handle it properly. I've created the function that will read only the first parameter and ignore the rest. 

        'call     PortalId = GetIntFromQueryString(Request, "portalid", PortalId) '14/3/2006

        Shared Function GetIntFromQueryString(ByVal Request As HttpRequest, ByVal key As String, ByVal nDefault As Integer) As Integer

            Dim nValue As Integer = nDefault

            Dim sQueryStringValues As String = Request.QueryString(key)

            If Not (sQueryStringValues Is Nothing) Then

                Try

                    nValue = Int32.Parse(sQueryStringValues)

                Catch

                    'By some reason (not fully investigated) sometimes QueryString has the same parameter inserted more that once,

                    'e.g "PortalID=0&PortalId=0" so QueryString(key) will be "0,0"

                    Dim asValues() As String = sQueryStringValues.Split(","c)

                    If asValues.Length > 0 Then

                        nValue = Int32.Parse(asValues(0))

                    End If

                End Try

            End If

            Return nValue

        End Function

I noticed that DNN Support has a few bug reports with exception “Input string was not in a correct format” (here, here, here and here) .May be some of them are caused by the same reason as mine.

 

posted @ Tuesday, March 14, 2006 8:31 AM

Print

Comments on this entry:

# re: Handle duplicate parameters in DotNetNuke UrlRewriteModule.

Left by web development company at 8/19/2009 10:39 AM
Gravatar
Quite inspiring,

um I thought I was the only one with this problem but when I saw yours I realized that my code was fine and there is a bug in the platform

Thanks for bringing this up

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345