Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Reason for app.Response.ContentType being Null in CompressionModule.vb?Reason for app.Response.ContentType being Null in CompressionModule.vb?
Previous
 
Next
New Post
1/7/2010 6:03 PM
 

Hello, I am using DNN 4.9.1 and I have recently encountered an intermittent problem in the "CompressContent" method within the "CompressionModule.vb" source file in DNN.  At times, the following line raises an exception:

If app.Response.ContentType.ToLower() <> "text/html" then

It errors because app.Response.ContentType is null.

It seems this does not happen if I am logged on as Host.  When I am using the site anonymously, it happens frequently.  And then, at other times, it's okay.  Any ideas on how to resolve this and why this might be occurring?

This is in the context of developing a new module which, so far has been going quite well.  It is only now, near the very end that I am suddenly encountering this problem.  The problem showed itself by the navigation links on the page (paging to display the next set of data) not responding to mouse-clicks when not logged on.  In addition I should note that this happens when the Website is hosted either of two 2 different servers.  I am using IE 6 for testing, as that is what our deployment environment is.

I have tried putting a line in CompressionModule.vb just above the one that errors-out, checking to see if app.Response.ContentType is null and exiting the sub for when that happens, but that hasn't helped.

Thanks in advance for your thoughts on this.

 

 
New Post
1/7/2010 9:19 PM
 

very strange, which ASP.Net version are you using?

besides, I suggest tu upgrade quickly to 4.9.5 for security reasons.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/8/2010 6:35 PM
 

Hello Sebastian. Thank you for your response.  The version of ASP.Net I am using is 2.0.50727 and I am using Visual Studio 2008 for development. Thanks for the suggestion on upgrading.

I think I am able to rule something out now (which is a sort of progress). Although the app.Response.ContentType is null (as my previous message states), I have found that if I remove the AddEvent code to prevent calling CompressionModule.vb, my page still does not handle client-side events. So that may be a bit of red herring.

Further testing (and head-scratching) indicate that the basic problem boils down to this: 

For background, what I have done is develop a DNN module with an intitial "view" page made for displaying employees, along with a text box used for entering search criteria.

I have written this module similar to the "efforty.UserDirectory" module, if you have seen that. Similarly, I register java script in the Page_Load event to handle, client-side, key press events in the search text box, so that the table and its contents (fed by changes to a filter on a dataview) can be redrawn rapidly.

It works just fine... as long as I am logged in as "Host" or "Admin".  But if I am on the site anonymously or logged on as a non-admin user, suddenly the events are no longer caught (i.e. the key press events in the textbox no longer get passed along to the javascript event handler).  Or, more accurately, most of the time they aren't.  Sometimes, after having been logged on as Host or Admin and having logged off, the events seem to be caught again.  When that happens, if I do a refresh on the page, the page will stop responding to events again.  It's odd...

Does this additional background give you any ideas?  I would sure like to get to the bottom of this.  Is it perhaps something to do with the page (classified as "view" in the .dnn file, btw) is being run in a partial rendering mode when Host/Admin are not logged on?  I ran into that problem once, when trying to make a Settings page accessible via a non-Host/non-Admin user (to get around it, I had to add a Framework.AJAX.RegisterPostBackControl() call in the page's Init event handler).


For further background, in order to bring in callback support, I declared the page's class as:

Partial Class ViewPhotoStaffDirectory
    Inherits Entities.Modules.PortalModuleBase
    Implements Entities.Modules.IActionable
    Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler


Also, if it helps, the following function is called on the Page_Load, to add the client-side script:


    Private Sub RegisterJSFunction()

      Dim script As New System.Text.StringBuilder

      With script

        .Append("<script language=""javascript"">")
        .Append(vbCrLf)

        'SendToPhotoDirectoryUD and success/error functions

        .Append("function SendToPhotoDirectoryUD(page) {")
        .Append(vbCrLf)

        .Append( _
            ClientAPI.GetCallbackEventReference(Me, _
                "'1|1|' + dnn.dom.getById('" + Me.txtSearch.UniqueID.Replace("$", "_") + _
                    "').value + '|' + page + '|'", _
                "successPhotoDirectoryFunc", _
                "this", _
                "errorPhotoDirectoryFunc" _
            ) _
        )

        .Append(vbCrLf)

        .Append("}")

        .Append(vbCrLf)

        .Append("function successPhotoDirectoryFunc(result, ctx) {" + vbCrLf)
        .Append("dnn.dom.getById('" + HtmlPhotoDirectoryAnker.UniqueID.Replace("$", "_") + _
                "').innerHTML = result }" + vbCrLf)

        .Append("function errorPhotoDirectoryFunc(result, ctx) {" + vbCrLf)
        .Append("}")

        .Append(vbCrLf)

        .Append("</script>" + vbCrLf)

      End With

      ' Get a ClientScriptManager reference from the Page class.
      Dim cs As ClientScriptManager = Page.ClientScript
      Dim cstype As Type = Me.GetType()

      ' Check to see if the client script is already registered.
      If (Not cs.IsClientScriptBlockRegistered(cstype, "SendToPhotoDirectoryUD")) Then

        cs.RegisterClientScriptBlock(cstype, "SendToPhotoDirectoryUD", script.ToString(), False)

      End If

    End Sub


In addition, the VB code that handles the callbacks is shown below:


    Public Function RaiseClientAPICallbackEvent(ByVal eventArgument As String) As String Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler.RaiseClientAPICallbackEvent

      Dim strArray As String() = eventArgument.Split("|")

      ' param 0 = CallBackMode; Search, sort or edit
      ' param 1 = SearchMode; fix or custom
      ' param 2 = search expression 
      ' param 3 = page
      ' param 4 = sortColumn or Staff ID

      Dim callBackMode As CallBackMode = CType(strArray(0), CallBackMode)

      Dim searchMode As SearchMode = CType(strArray(1), SearchMode)

      Dim searchExpression As String

      Dim strSearch As String = strArray(2)
      SearchFieldString = strSearch

      searchExpression = BuildSearchExpression(strSearch)

      Dim cntrlrPhotoStaffDirectorys As New PhotoStaffDirectoryController
      Dim dv As DataView = cntrlrPhotoStaffDirectorys.GetEmployeesTable(ModuleIDToUse, _
                                                                        DefaultSortExpression)

      dv.RowFilter = searchExpression

      Dim page As Int32

      If Not String.IsNullOrEmpty(strArray(3)) Then
        page = CInt(strArray(3))
        Session(SESSION_PAGE) = CStr(page)
      Else
        If Not Session(SESSION_PAGE) Is Nothing Then
          page = CInt(Session(SESSION_PAGE))
        Else
          page = 1
        End If
      End If

      If strSearch.Length >= MinChar Or SearchStartMode = _
          SearchStartMode.ShowAllRecords Then

        Return Me.BuildHtmlTableBrowser(dv, page)

      Else

        Return "<span class='Normal'>No Results</span>"

      End If

      Return HtmlPhotoDirectoryAnker.InnerHtml

    End Function

Thanks again, in advance. I really appreciate your help.

 

 
New Post
1/13/2010 6:14 PM
 

Hello again, Sebastian.  I'm just getting back to you (and any others who read this) to let you know I have found the cause of the problem and what the solution is.

It's really very simple.  The callbacks were not working because, when I added the module to a DNN page, the "cache" was set to a non-zero value.  Once I set cache to zero, everything worked!

It was kind of confusing because, when logged in as Host or Admin, the module worked.  So I suppose, behind the scenes, the DNN framework is setting cache to zero (regardless of what the module settings are), since admin work does not demand such high performance.

So anyway, I thought I'd share that, in case it helps anyone else.  Thanks for taking an interest.

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Reason for app.Response.ContentType being Null in CompressionModule.vb?Reason for app.Response.ContentType being Null in CompressionModule.vb?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out