• 12
• 12
• 9
• 10
• 13

# [web] Functions in Global.asax

This topic is 4153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a problem that I can't solve for quite a while now. I need a page that uses XslCompiledTransform and has quite enormous hit count. In order to avoid recompiling of the xsl, I would like to keep the XslCompiledTransform in global.asax and reference it from the codebehind of the page I'm using. The code I wrote seems to work just fine in debug/non-published configurations, but throws null reference exception when published.
<%@ Application Language="VB" %>

<object id="transformer" runat="server" scope="application" class="System.Xml.Xsl.XslCompiledTransform" />

<script runat="server">

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
'System.Diagnostics.Debugger.Break()
Try
System.Diagnostics.Debugger.Break()
Catch ex As Exception
System.Diagnostics.Debugger.Break()
End Try
System.Diagnostics.Debugger.Break()
Application("transformer") = transformer
End Sub


and I'm accessing the transformer like this
Dim transformer As Xsl.XslCompiledTransform = Application("transformer")


EDIT: When I managed to break into debugger, I couldn't see the troubling code because of 'the code is optimized'