Compilation debug=false in web.config gives errors in application

J

Jonas

Hi,

I've recently found out that I'm supposed to set the debug attribute of the
compilation element in web.config to false in production environments. But
when I do so in my ASP.NET application, I get strange errors. Apparently, a
javascript file that I specify in the vb-code doesn't get called, I and when
I check the source sent to the browser, I can see that the call to the
javascript file is changed so that the filename is prefixed by an
underscore, see first line below. But not all calls are modified, see second
line below.

<script language=javascript src="./WebModules/Scripts/_UsrsDetail.js"
</script>

<script language='javascript'
src='./WebModules/Scripts/cmAddress.js'></script>

The name of the script file failing is the same as the ascx-file calling it
(usrsdetail.asxc).

What happens when I change the debug switch??

TIA

Jonas
 
J

Jonas

I've solved the problem. I use a base class for the ascx control loaded, and
in the page_load event I retrieved the name of the derived ascx by the
sender parameter which apparently got prefixed with an underscore when run
in non-debug mode.

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

_strUniqueName = sender.ToString.Replace("ASP.", "").Replace("_ascx",
"").Replace("_aspx", "")

Now I use this code instead and it works:

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

_strUniqueName = Me.GetType.Name.Replace("_ascx", "")

/Jonas
 
Joined
Dec 2, 2010
Messages
1
Reaction score
0
Thanks!

Jonas,

Thank you for this post! I too was relying on GetType to behave consistently whether debug was true or false in the compilation element in Web.config. I will add that I only saw the problem after moving my app from a pre-IIS7 server to an IIS7 server.

-- Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top