Showing posts with label written. Show all posts
Showing posts with label written. Show all posts

Saturday, March 31, 2012

Strange Behavior for Pages Named Default.aspx

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?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 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?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 Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as "??áàéí" when I load the data again I get a few strange characters: "?§?£??? ???"

What is going wrong here?

How can I solve this?

Thanks,
Miguel

What encoding did you set for the pages? Set the responseEncoding to "utf-8"

Check this link on how to set it in the web.config filehttp://msdn2.microsoft.com/en-us/library/hy4kkhe0(vs.80).aspx

Thanks

Strange Characters in Asp.Net Text Box

Hello,
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"=E7=E3=E1=E0=E9=ED" when I load the data again I get a few strange charact=
ers:
"=C3=A7=C3=A3=C3=A1=C3 =C3=A9=C3"
What is going wrong here?
How can I solve this?
Thanks,
MiguelHello shapper,
This seems like a flaw in Unicode encoding mode in your URL If the character
s
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advance
d
Save Options' which does this.
Thanks
Cyril Gupta
-- You can do anything with a little bit of 'magination.
-- I've been programming so long, my brain is now software.

> Hello,
> I have a form which saves some data to an SQL 2005 database
> If the text written in the text box contains characters such as
> "" when I load the data again I get a few strange characters:
> "??á é"
> What is going wrong here?
> How can I solve this?
> Thanks,
> Miguel

Strange Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"

What is going wrong here?

How can I solve this?

Thanks,
MiguelHello shapper,

This seems like a flaw in Unicode encoding mode in your URL If the characters
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advanced
Save Options' which does this.

Thanks
Cyril Gupta

-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.

Quote:

Originally Posted by

Hello,
>
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"
What is going wrong here?
>
How can I solve this?
>
Thanks,
Miguel

Saturday, March 24, 2012

Strange exceptions in ASP.NET + COM application

Hello!

We have some code that is written in COM. It was used in a
"ISAPI-extension server " and everithing was fine. And it is fine at
the moment.

But now this code is used from the ASP.NET server. And we receive some
unknown exceptions. Them occurs after a long period of working (about
of 10,000 stress-test-queries). We can't ever recognize these
exceptions.

For example, yesterday I've received an exception in the method:

STDMETHODIMP CGobiSrv::put_FSCreator(IUnknown* fsCreator)
{
SAFE_METHOD_START("CGobiSrv::put_FSCreator")
AFX_MANAGE_STATE(AfxGetStaticModuleState())
serve->SetFSCreator( fsCreator );
GTRACEL("FSCreator received\n");
return S_OK;
SAFE_METHOD_END
}

We try to catch exceptions using the following code:

#define SAFE_METHOD_START(method_name) \
CMethodExecutionViewer method_ex_viewer( this->GetClassID(),
this->GetInstanceNum(), method_name ); \
try { \

#define SAFE_METHOD_END \
} catch (std::exception& e) { \
method_ex_viewer.ViewException( "standard", e.what() ); \
return E_FAIL; \
} catch (CException* e) { \
const int MAX_ERR_LEN = 256; \
GBuffer<TCHAR> err_msg(MAX_ERR_LEN); \
e->GetErrorMessage( err_msg, MAX_ERR_LEN ); \
method_ex_viewer.ViewException( _TEXT("MFC"), static_cast<TCHAR*>(
err_msg ) ); \
return E_FAIL; \
} catch (_com_error &e) { \
method_ex_viewer.ViewException( _TEXT("COM"), e.ErrorMessage() ); \
return E_FAIL; \
} catch (CAtlException &e) { \
const int MAX_ERR_LEN = 256; \
GBuffer<TCHAR> hr_code(MAX_ERR_LEN); \
ltoa(e, hr_code, 16); \
method_ex_viewer.ViewException( _TEXT("ATL"), static_cast<TCHAR*>(
hr_code ) ); \
return E_FAIL; \
} catch (...) { \
method_ex_viewer.ViewException( "unknown", "" ); \
return E_FAIL; \
} \

and our exceptions are always fall into the catch (...) section.

There is some EnterCriticalSection()/LeaveCriticalSection() that occurs
in SetFSCreator() method because of the fact that some global data is
shared between COM-objects. It's is because we use very legacy code.
Maybe the error is somewhere in interlocking, but why it's working in
the ISAPI-mode?

We use _ATL_APARTMENT_THREADED. We tried to run ASP script with and
without ASPCompat="true". We tried to run on .NET 1.1 and .NET 2.0. The
song remains the same.

It's very hard to debug. Because these exceptions occurs in different
places and after a long time of working.

Can anybody help us?

--
Danilyou need to set AspCompat=true, to support STA (apartment model) com
objects. also are you calling Marshal.ReleaseComObject(), to release the
object?

note: STA com objected can not be used directly from a webservice.

-- bruce (sqlwork.com)

<danil.shopyrin@.gmail.com> wrote in message
news:1142265254.460924.183160@.i39g2000cwa.googlegr oups.com...
> Hello!
> We have some code that is written in COM. It was used in a
> "ISAPI-extension server " and everithing was fine. And it is fine at
> the moment.
> But now this code is used from the ASP.NET server. And we receive some
> unknown exceptions. Them occurs after a long period of working (about
> of 10,000 stress-test-queries). We can't ever recognize these
> exceptions.
> For example, yesterday I've received an exception in the method:
> STDMETHODIMP CGobiSrv::put_FSCreator(IUnknown* fsCreator)
> {
> SAFE_METHOD_START("CGobiSrv::put_FSCreator")
> AFX_MANAGE_STATE(AfxGetStaticModuleState())
> serve->SetFSCreator( fsCreator );
> GTRACEL("FSCreator received\n");
> return S_OK;
> SAFE_METHOD_END
> }
> We try to catch exceptions using the following code:
> #define SAFE_METHOD_START(method_name) \
> CMethodExecutionViewer method_ex_viewer( this->GetClassID(),
> this->GetInstanceNum(), method_name ); \
> try { \
> #define SAFE_METHOD_END \
> } catch (std::exception& e) { \
> method_ex_viewer.ViewException( "standard", e.what() ); \
> return E_FAIL; \
> } catch (CException* e) { \
> const int MAX_ERR_LEN = 256; \
> GBuffer<TCHAR> err_msg(MAX_ERR_LEN); \
> e->GetErrorMessage( err_msg, MAX_ERR_LEN ); \
> method_ex_viewer.ViewException( _TEXT("MFC"), static_cast<TCHAR*>(
> err_msg ) ); \
> return E_FAIL; \
> } catch (_com_error &e) { \
> method_ex_viewer.ViewException( _TEXT("COM"), e.ErrorMessage() ); \
> return E_FAIL; \
> } catch (CAtlException &e) { \
> const int MAX_ERR_LEN = 256; \
> GBuffer<TCHAR> hr_code(MAX_ERR_LEN); \
> ltoa(e, hr_code, 16); \
> method_ex_viewer.ViewException( _TEXT("ATL"), static_cast<TCHAR*>(
> hr_code ) ); \
> return E_FAIL; \
> } catch (...) { \
> method_ex_viewer.ViewException( "unknown", "" ); \
> return E_FAIL; \
> } \
> and our exceptions are always fall into the catch (...) section.
> There is some EnterCriticalSection()/LeaveCriticalSection() that occurs
> in SetFSCreator() method because of the fact that some global data is
> shared between COM-objects. It's is because we use very legacy code.
> Maybe the error is somewhere in interlocking, but why it's working in
> the ISAPI-mode?
> We use _ATL_APARTMENT_THREADED. We tried to run ASP script with and
> without ASPCompat="true". We tried to run on .NET 1.1 and .NET 2.0. The
> song remains the same.
> It's very hard to debug. Because these exceptions occurs in different
> places and after a long time of working.
> Can anybody help us?
> --
> Danil
Dear Bruce,

thank you for your reply.

I try to use Marshal.ReleaseComObject(). I check the returm value and
it always equals to 0.

Exceptions are still here. The problem is that I don't know what to
catch. I don't understand what's happened. I afraid that something is
happened with the host aspnet_wp process.

There is anonther question. Is there a way to 'reboot' aspnet_wp
process sometimes? For example, one time for each 1000 requests. It can
help to avoid the problem, if we can't solve them.

Strange exceptions in ASP.NET + COM application

Hello!
We have some code that is written in COM. It was used in a
"ISAPI-extension server " and everithing was fine. And it is fine at
the moment.
But now this code is used from the ASP.NET server. And we receive some
unknown exceptions. Them occurs after a long period of working (about
of 10,000 stress-test-queries). We can't ever recognize these
exceptions.
For example, yesterday I've received an exception in the method:
STDMETHODIMP CGobiSrv::put_FSCreator(IUnknown* fsCreator)
{
SAFE_METHOD_START("CGobiSrv::put_FSCreator")
AFX_MANAGE_STATE(AfxGetStaticModuleState
())
serve->SetFSCreator( fsCreator );
GTRACEL("FSCreator received\n");
return S_OK;
SAFE_METHOD_END
}
We try to catch exceptions using the following code:
#define SAFE_METHOD_START(method_name) \
CMethodExecutionViewer method_ex_viewer( this->GetClassID(),
this->GetInstanceNum(), method_name ); \
try { \
#define SAFE_METHOD_END \
} catch (std::exception& e) { \
method_ex_viewer.ViewException( "standard", e.what() ); \
return E_FAIL; \
} catch (CException* e) { \
const int MAX_ERR_LEN = 256; \
GBuffer<TCHAR> err_msg(MAX_ERR_LEN); \
e->GetErrorMessage( err_msg, MAX_ERR_LEN ); \
method_ex_viewer.ViewException( _TEXT("MFC"), static_cast<TCHAR*>(
err_msg ) ); \
return E_FAIL; \
} catch (_com_error &e) { \
method_ex_viewer.ViewException( _TEXT("COM"), e.ErrorMessage() ); \
return E_FAIL; \
} catch (CAtlException &e) { \
const int MAX_ERR_LEN = 256; \
GBuffer<TCHAR> hr_code(MAX_ERR_LEN); \
ltoa(e, hr_code, 16); \
method_ex_viewer.ViewException( _TEXT("ATL"), static_cast<TCHAR*>(
hr_code ) ); \
return E_FAIL; \
} catch (...) { \
method_ex_viewer.ViewException( "unknown", "" ); \
return E_FAIL; \
} \
and our exceptions are always fall into the catch (...) section.
There is some EnterCriticalSection()/LeaveCriticalSection() that occurs
in SetFSCreator() method because of the fact that some global data is
shared between COM-objects. It's is because we use very legacy code.
Maybe the error is somewhere in interlocking, but why it's working in
the ISAPI-mode?
We use _ATL_APARTMENT_THREADED. We tried to run ASP script with and
without ASPCompat="true". We tried to run on .NET 1.1 and .NET 2.0. The
song remains the same.
It's very hard to debug. Because these exceptions occurs in different
places and after a long time of working.
Can anybody help us?
Danilyou need to set AspCompat=true, to support STA (apartment model) com
objects. also are you calling Marshal.ReleaseComObject(), to release the
object?
note: STA com objected can not be used directly from a webservice.
-- bruce (sqlwork.com)
<danil.shopyrin@.gmail.com> wrote in message
news:1142265254.460924.183160@.i39g2000cwa.googlegroups.com...
> Hello!
> We have some code that is written in COM. It was used in a
> "ISAPI-extension server " and everithing was fine. And it is fine at
> the moment.
> But now this code is used from the ASP.NET server. And we receive some
> unknown exceptions. Them occurs after a long period of working (about
> of 10,000 stress-test-queries). We can't ever recognize these
> exceptions.
> For example, yesterday I've received an exception in the method:
> STDMETHODIMP CGobiSrv::put_FSCreator(IUnknown* fsCreator)
> {
> SAFE_METHOD_START("CGobiSrv::put_FSCreator")
> AFX_MANAGE_STATE(AfxGetStaticModuleState
())
> serve->SetFSCreator( fsCreator );
> GTRACEL("FSCreator received\n");
> return S_OK;
> SAFE_METHOD_END
> }
> We try to catch exceptions using the following code:
> #define SAFE_METHOD_START(method_name) \
> CMethodExecutionViewer method_ex_viewer( this->GetClassID(),
> this->GetInstanceNum(), method_name ); \
> try { \
> #define SAFE_METHOD_END \
> } catch (std::exception& e) { \
> method_ex_viewer.ViewException( "standard", e.what() ); \
> return E_FAIL; \
> } catch (CException* e) { \
> const int MAX_ERR_LEN = 256; \
> GBuffer<TCHAR> err_msg(MAX_ERR_LEN); \
> e->GetErrorMessage( err_msg, MAX_ERR_LEN ); \
> method_ex_viewer.ViewException( _TEXT("MFC"), static_cast<TCHAR*>(
> err_msg ) ); \
> return E_FAIL; \
> } catch (_com_error &e) { \
> method_ex_viewer.ViewException( _TEXT("COM"), e.ErrorMessage() ); \
> return E_FAIL; \
> } catch (CAtlException &e) { \
> const int MAX_ERR_LEN = 256; \
> GBuffer<TCHAR> hr_code(MAX_ERR_LEN); \
> ltoa(e, hr_code, 16); \
> method_ex_viewer.ViewException( _TEXT("ATL"), static_cast<TCHAR*>(
> hr_code ) ); \
> return E_FAIL; \
> } catch (...) { \
> method_ex_viewer.ViewException( "unknown", "" ); \
> return E_FAIL; \
> } \
> and our exceptions are always fall into the catch (...) section.
> There is some EnterCriticalSection()/LeaveCriticalSection() that occurs
> in SetFSCreator() method because of the fact that some global data is
> shared between COM-objects. It's is because we use very legacy code.
> Maybe the error is somewhere in interlocking, but why it's working in
> the ISAPI-mode?
> We use _ATL_APARTMENT_THREADED. We tried to run ASP script with and
> without ASPCompat="true". We tried to run on .NET 1.1 and .NET 2.0. The
> song remains the same.
> It's very hard to debug. Because these exceptions occurs in different
> places and after a long time of working.
> Can anybody help us?
> --
> Danil
>
Dear Bruce,
thank you for your reply.
I try to use Marshal.ReleaseComObject(). I check the returm value and
it always equals to 0.
Exceptions are still here. The problem is that I don't know what to
catch. I don't understand what's happened. I afraid that something is
happened with the host aspnet_wp process.
There is anonther question. Is there a way to 'reboot' aspnet_wp
process sometimes? For example, one time for each 1000 requests. It can
help to avoid the problem, if we can't solve them.