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...Building ExtensionsBuilding ExtensionsSkinsSkinsSkin object or module to access/use session and application startSkin object or module to access/use session and application start
New Post
7/7/2012 2:11 AM

I've been doing a lot of searching and I can't nail down exactly to how to accomplish this...

What I want to do is create a simple (unique) visitor counter on my DNN 6.1.5 site.  I have a lot of experience with ASP programming and a little bit with ASP.NET.  I prefer to avoid bulky third party hit counting modules.  Also, I have never seen one of those that will work for me--I want to grab the raw number of hits and I need to place it in a footer.   Some hit count modules do provide tokens, such as [TEXTHITCOUNT] or whatnot, but I cannot use the replace tokens option because I don't need/want the hit count displayed inside of a container--I need to display it in a stand-alone .aspx file.

Anyway, with a normal ASP.NET application, I could simply add code in global.aspx so that on Application_start, I create and initialize a hitcount variable.  Then I would increment that variable on Session_start.  I could then access that variable from anywhere I needed to.  I could then write the current count to a database or text file when the application is going to shut down, so that my hit count is persistent through server restarts, etc.

Through my research, it seems I cannot do this in DNN 6.  I see the global.aspx file but it contains only one line of code:
<%@ Application Codebehind="Global.asax.cs" Inherits="DotNetNuke.Common.DotNetNukeHttpApplication" Language="C#" %>

So there is no code behind file specified.  I understand from research that DNN actually consumes the event information via the DotNetNukeHttpApplication module:

Finally, I have many articles that describe creating custom Http modules for DNN and I finally gave up because I always hit issues that I cannot work past.  So I instead turned to trying to create my own skin object/control to do the same thing.  But again, I have failed to find a concrete example of accessing the equivalent events/information of Application_Start and Session_Start from within a skin object/control.

Can anyone provide me with a concrete code example of accessing/using the Application_Start and Session_Start events from within the DNN framework, preferably via a skin control/object?

(Sorry for the long description but I assure you this is not one of those lazy posts trying to get someone to do the work for me.  I have spent over a week writing code, researching, and exploring numerous avenues and have been left frustrated and broken...)

Please help!

New Post
7/8/2012 5:40 AM

The nature (and strengths) of DNN is it's extensibility.
I would advise you to use one of the common ways to extend DNN, to prevent upgrade issues in the future.

That means either skin object or a module in this case.
A skin object has the disadvantage that it's not as easy to store values as with a module.
A DNN module gives you easy access to "module settings", allowing you to store some values.
(for more complicated data storages you would use the DB)

I hope that set's you on the right track (there are enough sources about creating modules, try looking for a hello world example)

BTW, there is a setting to show a module on all page in the settings of the module in DNN.


New Post
7/10/2012 12:05 AM

Thank you for your reply.

I actually know how to create modules and skin objects.

What I cannot nail down is exactly how to access the session_start/end and application_start/end events that are, under a regular ASP.NET environment, accessible in global.asax.  Because all of the events are consumed in DNN 6, adding code in global.asax or in a code behind fie global.asax.cs, for example, does not work.

I would greatly appreciate an example of a module.ascx.cs code example that simply does something (anything) on application_start and something else on session_start (I can of course extrapolate how to do something on application/session_end from that).

I searched all through the API documentation for DNN 6.1, which is what I'm  using, and I cannot any reference to the application_start/end event.  I HAVE found references to what I believe is the equivalent of session_start/end events, but I am not sure.

I appreciate any help that anyone can provide in a small concrete example!

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsSkinsSkinsSkin object or module to access/use session and application startSkin object or module to access/use session and application start

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