Saturday, March 31, 2012
Strange Behavior for Pages Named Default.aspx
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Informational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
Does anyone know what causes this? How can I fix it?Hi Joey,
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
Milosz
"Joey" wrote:
> I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
> I like to create and track page view events, increment counters, etc.
> I do this in a block on each page, like this...
> protected void Page_Load(object sender, EventArgs e)
> {
> if(!this.Page.IsPostBack)
> {
> Event.Write(EventSource.UserActivity,EventType.Informational,"My
> event text");
> Counter.Hit(WebPage.MyPage);
> }
> }
> Now, for the problem. I noticed that many events are being written
> twice, and many counters are being incremented twice when viewing the
> page only once. When I set a breakpoint inside the code block above,
> for any page named "Default.aspx" (no matter where it is in the folder
> structure) the lines inside the code block execute twice. If I rename
> the page to something else, they execute only once, as expected.
> Does anyone know what causes this? How can I fix it?
>
On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:
> Hi Joey,
> Seems page events are fired twice because event handler is assigned two
> times - by the AutoWireupEvent directive and by your code by adding the
> handler explicitely (vb.net AddHandler or Handles clauses)
> --
> Milosz
>
> "Joey" wrote:
>
>
>
> - Show quoted text -
My code does not explicitly assign any event handlers.
Hi again Joey,
I hope you are well. Could you please paste both aspx page and code beside
so we could have a look?
--
Milosz
"Joey" wrote:
> On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
> wrote:
> My code does not explicitly assign any event handlers.
>
Strange Behavior for Pages Named Default.aspx
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
Does anyone know what causes this? How can I fix it?Hi Joey,
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
--
Milosz
"Joey" wrote:
Quote:
Originally Posted by
I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
>
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
>
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
>
Does anyone know what causes this? How can I fix it?
>
>
On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:
Quote:
Originally Posted by
Hi Joey,
>
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
>
--
Milosz
>
>
>
"Joey" wrote:
Quote:
Originally Posted by
I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
>
Quote:
Originally Posted by
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
>
Quote:
Originally Posted by
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
>
Quote:
Originally Posted by
Does anyone know what causes this? How can I fix it?- Hide quoted text -
>
- Show quoted text -
My code does not explicitly assign any event handlers.
Hi again Joey,
I hope you are well. Could you please paste both aspx page and code beside
so we could have a look?
--
Milosz
"Joey" wrote:
Quote:
Originally Posted by
On Jun 27, 5:38 pm, Milosz Skalecki [MCAD] <mily...@.DONTLIKESPAMwp.pl>
wrote:
Quote:
Originally Posted by
Hi Joey,
Seems page events are fired twice because event handler is assigned two
times - by the AutoWireupEvent directive and by your code by adding the
handler explicitely (vb.net AddHandler or Handles clauses)
--
Milosz
"Joey" wrote:
Quote:
Originally Posted by
I have several asp.net 2.0 apps written in VS2005 in C#. For each one,
I like to create and track page view events, increment counters, etc.
I do this in a block on each page, like this...
Quote:
Originally Posted by
protected void Page_Load(object sender, EventArgs e)
{
if(!this.Page.IsPostBack)
{
Event.Write(EventSource.UserActivity,EventType.Inf ormational,"My
event text");
Counter.Hit(WebPage.MyPage);
}
}
Quote:
Originally Posted by
Now, for the problem. I noticed that many events are being written
twice, and many counters are being incremented twice when viewing the
page only once. When I set a breakpoint inside the code block above,
for any page named "Default.aspx" (no matter where it is in the folder
structure) the lines inside the code block execute twice. If I rename
the page to something else, they execute only once, as expected.
Quote:
Originally Posted by
Does anyone know what causes this? How can I fix it?- Hide quoted text -
- Show quoted text -
>
My code does not explicitly assign any event handlers.
>
>
Wednesday, March 28, 2012
Strange compilation errors
d
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes are
declared as partial.
Any ideas what could be the problem?
Thanksyou should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.com> wrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
> Assuming two aspx pages named Defaul1 and Default2 whith separate code
> behind
> files. The corresponding class names are Defaul1 and Default2 respectively
> and are in the same namespace (MyCompany.MyApplication.UI).
> In the "Page_Load" of Page2 class I have the following code
> if ( Context.Handler is Page1 )
> Page1 sourcePage = (Page1)Context.Handler;
> Not allways but quite often during the build, I see the following error:
> The type or namespace name 'Page1' could not be found (are you missing a
> using directive or an assembly reference?)
> The error message appears twise indicating the two code lines above.
> There is no missing "using" because both classes are in the same
> namespace.
> There is no missing assemply reference because both classes (pages) are in
> the same web project.
> The dev environment is VS 2005 and in the code behind files the classes
> are
> declared as partial.
> Any ideas what could be the problem?
> Thanks
>
And how can I add a reference to Default1 in Default2 ?
"bruce barker (sqlwork.com)" wrote:
> you should not confuse namespaces with assemblies. namespace is just that,
a
> naming prefix. using a namespace just allows shortcuts in speciing names.
> several assemblies (dlls) may use the same namespace, or one assembly may
> have several namespaces. to reference a routine, you must specify the nam
e,
> but also must include the assembly containing the routine.
> asp.net builds an assembly per page, so even though you use the same
> namespace, you als need to add a reference to the page. a confusing facter
> is that asp.net will compile serveral pages into the same dll if batching
is
> allowed. if you forgt the refernce and the pages end up in the same assemb
ly
> your ok. if they end up in different assemblies, then you're in trouble.
> -- bruce (sqlwork.com)
> "Argirop" <Argirop@.discussions.microsoft.com> wrote in message
> news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
>
>
Never mind, I found it.
Thanks a lot.
"Argirop" wrote:
> And how can I add a reference to Default1 in Default2 ?
> "bruce barker (sqlwork.com)" wrote:
>
Strange compilation errors
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes are
declared as partial.
Any ideas what could be the problem?
Thanksyou should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
>
In the "Page_Load" of Page2 class I have the following code
>
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
>
Not allways but quite often during the build, I see the following error:
>
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
>
The error message appears twise indicating the two code lines above.
>
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
>
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
>
Any ideas what could be the problem?
>
Thanks
>
>
And how can I add a reference to Default1 in Default2 ?
"bruce barker (sqlwork.com)" wrote:
Quote:
Originally Posted by
you should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
>
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
>
-- bruce (sqlwork.com)
>
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
In the "Page_Load" of Page2 class I have the following code
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
Not allways but quite often during the build, I see the following error:
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
The error message appears twise indicating the two code lines above.
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
Any ideas what could be the problem?
Thanks
>
>
>
Never mind, I found it.
Thanks a lot.
"Argirop" wrote:
Quote:
Originally Posted by
And how can I add a reference to Default1 in Default2 ?
>
"bruce barker (sqlwork.com)" wrote:
>
Quote:
Originally Posted by
you should not confuse namespaces with assemblies. namespace is just that, a
naming prefix. using a namespace just allows shortcuts in speciing names.
several assemblies (dlls) may use the same namespace, or one assembly may
have several namespaces. to reference a routine, you must specify the name,
but also must include the assembly containing the routine.
asp.net builds an assembly per page, so even though you use the same
namespace, you als need to add a reference to the page. a confusing facter
is that asp.net will compile serveral pages into the same dll if batching is
allowed. if you forgt the refernce and the pages end up in the same assembly
your ok. if they end up in different assemblies, then you're in trouble.
-- bruce (sqlwork.com)
"Argirop" <Argirop@.discussions.microsoft.comwrote in message
news:8B674FC6-4D83-4D02-8076-1EA6D72E804E@.microsoft.com...
Quote:
Originally Posted by
Assuming two aspx pages named Defaul1 and Default2 whith separate code
behind
files. The corresponding class names are Defaul1 and Default2 respectively
and are in the same namespace (MyCompany.MyApplication.UI).
>
In the "Page_Load" of Page2 class I have the following code
>
if ( Context.Handler is Page1 )
Page1 sourcePage = (Page1)Context.Handler;
>
Not allways but quite often during the build, I see the following error:
>
The type or namespace name 'Page1' could not be found (are you missing a
using directive or an assembly reference?)
>
The error message appears twise indicating the two code lines above.
>
There is no missing "using" because both classes are in the same
namespace.
There is no missing assemply reference because both classes (pages) are in
the same web project.
>
The dev environment is VS 2005 and in the code behind files the classes
are
declared as partial.
>
Any ideas what could be the problem?
>
Thanks
>
>