Showing posts with label creating. Show all posts
Showing posts with label creating. Show all posts

Saturday, March 24, 2012

this.Controls.Add(Control) Does Not Add Control to child collection (this.Controls.Count =

Ok, as silly as it may sound, I have a situation where I am creating a
CompositeControl in ASP.NET 2.0, C#. I have the following code in the
CreateChildControls() method that build the control's child control
collection:

for (int i = 0; i < _menus.Count; i++)
this.Controls.Add(_menus[i]);

foreach (FloatingMenu menu in _menus)
{
Label lbl = new Label();
lbl.ID = string.Concat("GroupQ", menu.ID);
lbl.CssClass = "menuItemGroupHeader";
lbl.Text = menu.GroupName;
this.Controls.Add(lbl);

HoverMenuExtender extender = new HoverMenuExtender();
extender.ID = string.Concat("ExtenderQ", menu.ID);
extender.TargetControlID = lbl.ID;
extender.PopupControlID = menu.ID;
extender.PopupPosition = HoverMenuPopupPosition.Bottom;
this.Controls.Add(extender);
}

The amazing thing is here, that the Label control and the HoverMenuExtender
AJAX Toolkit control both get added just fine, however I added a watch on
this.Controls.Count for the line where I add my FloatingMenu control
collection, "_menus", and after each call to "this.Controls.Add(_menus[i]);"
the Count is 0, however after I add the label it's 1 and the extender it's
2.

I'm stumped.

Thanks,
ChadWhat is the value of _menus.Count before the for loop

"Chad Scharf" <chadscharf@.community.nospamwrote in message
news:%23qrSW5CEIHA.5752@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Ok, as silly as it may sound, I have a situation where I am creating a
CompositeControl in ASP.NET 2.0, C#. I have the following code in the
CreateChildControls() method that build the control's child control
collection:
>
for (int i = 0; i < _menus.Count; i++)
this.Controls.Add(_menus[i]);
>
foreach (FloatingMenu menu in _menus)
{
Label lbl = new Label();
lbl.ID = string.Concat("GroupQ", menu.ID);
lbl.CssClass = "menuItemGroupHeader";
lbl.Text = menu.GroupName;
this.Controls.Add(lbl);
>
HoverMenuExtender extender = new HoverMenuExtender();
extender.ID = string.Concat("ExtenderQ", menu.ID);
extender.TargetControlID = lbl.ID;
extender.PopupControlID = menu.ID;
extender.PopupPosition = HoverMenuPopupPosition.Bottom;
this.Controls.Add(extender);
}
>
>
The amazing thing is here, that the Label control and the
HoverMenuExtender AJAX Toolkit control both get added just fine, however I
added a watch on this.Controls.Count for the line where I add my
FloatingMenu control collection, "_menus", and after each call to
"this.Controls.Add(_menus[i]);" the Count is 0, however after I add the
label it's 1 and the extender it's 2.
>
I'm stumped.
>
Thanks,
Chad
>


_menus.Count is 2 before the loop. And the second, foreach loop adds 2
Labels and 2 HoverMenuExtenders as it should. I tried the first loop with a
foreach initially, but remembering SyncRoot issues and thought perhaps the
enumerator was breaking the Add operation, I changed it to the for loop to
no avail.

"IfThenElse" <sql_agentman@.hotmail.comwrote in message
news:%23D0oraEEIHA.6120@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

What is the value of _menus.Count before the for loop
>
>
"Chad Scharf" <chadscharf@.community.nospamwrote in message
news:%23qrSW5CEIHA.5752@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Ok, as silly as it may sound, I have a situation where I am creating a
>CompositeControl in ASP.NET 2.0, C#. I have the following code in the
>CreateChildControls() method that build the control's child control
>collection:
>>
>for (int i = 0; i < _menus.Count; i++)
>this.Controls.Add(_menus[i]);
>>
>foreach (FloatingMenu menu in _menus)
>{
>Label lbl = new Label();
>lbl.ID = string.Concat("GroupQ", menu.ID);
>lbl.CssClass = "menuItemGroupHeader";
>lbl.Text = menu.GroupName;
>this.Controls.Add(lbl);
>>
>HoverMenuExtender extender = new HoverMenuExtender();
>extender.ID = string.Concat("ExtenderQ", menu.ID);
>extender.TargetControlID = lbl.ID;
>extender.PopupControlID = menu.ID;
>extender.PopupPosition = HoverMenuPopupPosition.Bottom;
>this.Controls.Add(extender);
>}
>>
>>
>The amazing thing is here, that the Label control and the
>HoverMenuExtender AJAX Toolkit control both get added just fine, however
>I added a watch on this.Controls.Count for the line where I add my
>FloatingMenu control collection, "_menus", and after each call to
>"this.Controls.Add(_menus[i]);" the Count is 0, however after I add the
>label it's 1 and the extender it's 2.
>>
>I'm stumped.
>>
>Thanks,
>Chad
>>


>
>


Does anyone have any clue why this would happen? I'm still banging my head
against a wall trying to figure this out.

"Chad Scharf" <chadscharf@.community.nospamwrote in message
news:%23qrSW5CEIHA.5752@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Ok, as silly as it may sound, I have a situation where I am creating a
CompositeControl in ASP.NET 2.0, C#. I have the following code in the
CreateChildControls() method that build the control's child control
collection:
>
for (int i = 0; i < _menus.Count; i++)
this.Controls.Add(_menus[i]);
>
foreach (FloatingMenu menu in _menus)
{
Label lbl = new Label();
lbl.ID = string.Concat("GroupQ", menu.ID);
lbl.CssClass = "menuItemGroupHeader";
lbl.Text = menu.GroupName;
this.Controls.Add(lbl);
>
HoverMenuExtender extender = new HoverMenuExtender();
extender.ID = string.Concat("ExtenderQ", menu.ID);
extender.TargetControlID = lbl.ID;
extender.PopupControlID = menu.ID;
extender.PopupPosition = HoverMenuPopupPosition.Bottom;
this.Controls.Add(extender);
}
>
>
The amazing thing is here, that the Label control and the
HoverMenuExtender AJAX Toolkit control both get added just fine, however I
added a watch on this.Controls.Count for the line where I add my
FloatingMenu control collection, "_menus", and after each call to
"this.Controls.Add(_menus[i]);" the Count is 0, however after I add the
label it's 1 and the extender it's 2.
>
I'm stumped.
>
Thanks,
Chad
>

Thursday, March 22, 2012

Thoughts about using Session variables for login security?

I am creating a simple website with a login page and some "admin only"
pages.
In my login page's submit button I just say if the "password is correct"
then...
session("IsAdmin") = True
In my admin only pages I check if session("IsAdmin") = True
If it's NOT then I redirect them to the login.aspx page.
Is this solution pretty solid, or is it easy to hack? I keep the password
in the web.config appsettings section so it's easy to change.
I know I could use Membership stuff, but I'm just doing a simple, quick
website.
Your thoughts are appreciated!Hello Bobby,

> I am creating a simple website with a login page and some "admin only"
> pages.
> In my login page's submit button I just say if the "password is
> correct"
> then...
> session("IsAdmin") = True
> In my admin only pages I check if session("IsAdmin") = True If it's
> NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? I keep the
> password in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple,
> quick website.
Membership is there, membership is quick and membership works out of the
box from the web.config if you need it to.
My experience is that this quick and simple website will run for the coming
20 years and that every time you need to change somthing you hoped you did
it the right way first time round...
--
Jesse Houwing
jesse.houwing at sogeti.nl
I've done the same thing in the past. There is one and only quesion
you need to ask: "is this doing what I need it to?" From your post the
answer is "yes," so you're good. But I see you're asking "is it easy
to hack?"
And the answer is a resounding "no." Session variables are stored in
the server's memory. In order to access them a hacker would need to
hack the server itself and gain access to it's memory. If that
happens, having them view your session variables would be the very
least of your concerns.
On Mar 5, 2:33=A0pm, "Bobby Edward" <t...@.test.com> wrote:
> I am creating a simple website with a login page and some "admin only"
> pages.
> In my login page's submit button I just say if the "password is correct"
> then...
> session("IsAdmin") =3D True
> In my admin only pages I check if session("IsAdmin") =3D True
> If it's NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? =A0I keep the passwo=[/color
]
rd
> in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple, quick
> website.
> Your thoughts are appreciated!
I'd look at Jesse's recommendation about using the built-in membership
system in ASP.Net 2.0 if you really want to have some flexibility. You can
then use Roles to manage your users. For administrators, you can create an
Admin role and assign the users to that role. Then all you have to do is
test if the user is in that role. Actually, better yet, you can set the
authorization section of the web.config file so that only certain users or
roles have access to particular files or folders. This let's you tweak
security in a config file without worrying about coding it in every single
page.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
"Bobby Edward" <test@.test.com> wrote in message
news:%23dULGfvfIHA.1188@.TK2MSFTNGP04.phx.gbl...
>I am creating a simple website with a login page and some "admin only"
>pages.
> In my login page's submit button I just say if the "password is correct"
> then...
> session("IsAdmin") = True
> In my admin only pages I check if session("IsAdmin") = True
> If it's NOT then I redirect them to the login.aspx page.
> Is this solution pretty solid, or is it easy to hack? I keep the password
> in the web.config appsettings section so it's easy to change.
> I know I could use Membership stuff, but I'm just doing a simple, quick
> website.
> Your thoughts are appreciated!
>

Thread execution report?

Hi, I am creating a newsletter system, and in the webform used to write and
send the newsletter I use a thread that sends all the newsletters, so that
when I write the newsletter I don't need to wait for all the mails to be
delivered, but it's the thread I launch that is responsible for the delivery
.
My question is, is there a way to have a report of the status of the deliver
y?
Since HTTP is stateless, I don't think there is a simple way to do this,
since, after I send the email and my request ends, I no longer have a way to
communicate with the thread which is still running on the server to send the
emails.
Do you have any suggestion?
Simone BusoliHave it send you an email.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Simone Busoli" <SimoneBusoli@.discussions.microsoft.com> wrote in message
news:B6C016E0-6099-4E60-9744-6BD7DEB0C06D@.microsoft.com...
> Hi, I am creating a newsletter system, and in the webform used to write
> and
> send the newsletter I use a thread that sends all the newsletters, so that
> when I write the newsletter I don't need to wait for all the mails to be
> delivered, but it's the thread I launch that is responsible for the
> delivery.
> My question is, is there a way to have a report of the status of the
> delivery?
> Since HTTP is stateless, I don't think there is a simple way to do this,
> since, after I send the email and my request ends, I no longer have a way
> to
> communicate with the thread which is still running on the server to send
> the
> emails.
> Do you have any suggestion?
> --
> Simone Busoli

Thread issue/leak?

I am creating a worker thread from inside an aspx page and the thread does
the stuff it should do, no problem.
However, I have noticed running it in the debugger that it seems as if the
threads are not killed/garbage-collected after a thread terminates. I have a
breakpoint in the thread itself and every time it breaks, in the Threads
window I observe the new thread, but the previous thread is still there as
well. The exact same code in a windows app performs as expected, on every
break there are two threads, the main thread and the current worker thread.
The simplified code below also gives the same results, so nothing strange in
the thread itself. If I put the code in a loop of 2000 cycles and break
after the last, then there are 2000 worker threads displayed in the Threads
window.

Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
ttt.ApartmentState = Threading.ApartmentState.STA
ttt.Start()
ttt.Join()

And the simple thread:

Private Sub TheThreadProc()
Dim iii As Integer = 10
End SubThis is because you are using a Single-Threaded Apartment. There is nothing
in the thread to receive messages. When you use COM in an ASP.Net
application, you create an Interop class that is disposable, and therefore,
the thread can be killed. IOW, don't use an STA thread unless you are doing
Interop.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>I am creating a worker thread from inside an aspx page and the thread does
> the stuff it should do, no problem.
> However, I have noticed running it in the debugger that it seems as if the
> threads are not killed/garbage-collected after a thread terminates. I have
> a
> breakpoint in the thread itself and every time it breaks, in the Threads
> window I observe the new thread, but the previous thread is still there as
> well. The exact same code in a windows app performs as expected, on every
> break there are two threads, the main thread and the current worker
> thread.
> The simplified code below also gives the same results, so nothing strange
> in
> the thread itself. If I put the code in a loop of 2000 cycles and break
> after the last, then there are 2000 worker threads displayed in the
> Threads
> window.
> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
> ttt.ApartmentState = Threading.ApartmentState.STA
> ttt.Start()
> ttt.Join()
> And the simple thread:
> Private Sub TheThreadProc()
> Dim iii As Integer = 10
> End Sub
Kevin, thanks for the response, however this is not it, I tested it without
STA before I posted the problem, same result.
The true thread is doing Interop, the simple example below is not (the
simple example produces the error/issue, with or without the STA statement).

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
> This is because you are using a Single-Threaded Apartment. There is
> nothing in the thread to receive messages. When you use COM in an ASP.Net
> application, you create an Interop class that is disposable, and
> therefore, the thread can be killed. IOW, don't use an STA thread unless
> you are doing Interop.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Everybody picks their nose,
> But some people are better at hiding it.
> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>I am creating a worker thread from inside an aspx page and the thread does
>> the stuff it should do, no problem.
>> However, I have noticed running it in the debugger that it seems as if
>> the
>> threads are not killed/garbage-collected after a thread terminates. I
>> have a
>> breakpoint in the thread itself and every time it breaks, in the Threads
>> window I observe the new thread, but the previous thread is still there
>> as
>> well. The exact same code in a windows app performs as expected, on every
>> break there are two threads, the main thread and the current worker
>> thread.
>> The simplified code below also gives the same results, so nothing strange
>> in
>> the thread itself. If I put the code in a loop of 2000 cycles and break
>> after the last, then there are 2000 worker threads displayed in the
>> Threads
>> window.
>>
>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>> ttt.ApartmentState = Threading.ApartmentState.STA
>> ttt.Start()
>> ttt.Join()
>>
>> And the simple thread:
>>
>> Private Sub TheThreadProc()
>> Dim iii As Integer = 10
>> End Sub
>>
>>
Are you setting the "aspcompat" attribute?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>> This is because you are using a Single-Threaded Apartment. There is
>> nothing in the thread to receive messages. When you use COM in an ASP.Net
>> application, you create an Interop class that is disposable, and
>> therefore, the thread can be killed. IOW, don't use an STA thread unless
>> you are doing Interop.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Everybody picks their nose,
>> But some people are better at hiding it.
>>
>> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
>> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>>I am creating a worker thread from inside an aspx page and the thread
>>>does
>>> the stuff it should do, no problem.
>>> However, I have noticed running it in the debugger that it seems as if
>>> the
>>> threads are not killed/garbage-collected after a thread terminates. I
>>> have a
>>> breakpoint in the thread itself and every time it breaks, in the Threads
>>> window I observe the new thread, but the previous thread is still there
>>> as
>>> well. The exact same code in a windows app performs as expected, on
>>> every
>>> break there are two threads, the main thread and the current worker
>>> thread.
>>> The simplified code below also gives the same results, so nothing
>>> strange in
>>> the thread itself. If I put the code in a loop of 2000 cycles and break
>>> after the last, then there are 2000 worker threads displayed in the
>>> Threads
>>> window.
>>>
>>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>>> ttt.ApartmentState = Threading.ApartmentState.STA
>>> ttt.Start()
>>> ttt.Join()
>>>
>>> And the simple thread:
>>>
>>> Private Sub TheThreadProc()
>>> Dim iii As Integer = 10
>>> End Sub
>>>
>>>
>>
>>
Also, Chris, as you didn't post your actual code, I can't really guess what
the problem is. However, I believe you can find your answers at one or more
of the following MSDN articles (and related links):

http://msdn.microsoft.com/library/e...asp?frame=true
http://msdn.microsoft.com/library/e...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>> This is because you are using a Single-Threaded Apartment. There is
>> nothing in the thread to receive messages. When you use COM in an ASP.Net
>> application, you create an Interop class that is disposable, and
>> therefore, the thread can be killed. IOW, don't use an STA thread unless
>> you are doing Interop.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Everybody picks their nose,
>> But some people are better at hiding it.
>>
>> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
>> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>>I am creating a worker thread from inside an aspx page and the thread
>>>does
>>> the stuff it should do, no problem.
>>> However, I have noticed running it in the debugger that it seems as if
>>> the
>>> threads are not killed/garbage-collected after a thread terminates. I
>>> have a
>>> breakpoint in the thread itself and every time it breaks, in the Threads
>>> window I observe the new thread, but the previous thread is still there
>>> as
>>> well. The exact same code in a windows app performs as expected, on
>>> every
>>> break there are two threads, the main thread and the current worker
>>> thread.
>>> The simplified code below also gives the same results, so nothing
>>> strange in
>>> the thread itself. If I put the code in a loop of 2000 cycles and break
>>> after the last, then there are 2000 worker threads displayed in the
>>> Threads
>>> window.
>>>
>>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>>> ttt.ApartmentState = Threading.ApartmentState.STA
>>> ttt.Start()
>>> ttt.Join()
>>>
>>> And the simple thread:
>>>
>>> Private Sub TheThreadProc()
>>> Dim iii As Integer = 10
>>> End Sub
>>>
>>>
>>
>>
worker threads should be terminated, as you showed code of one
statement.
There would be 2000 (caller) main threads waiting for worker to be
terminated.

If you are saying worker thread (small one statement proc) is not
terminating (GC)
then Caller threads must also be alive.

Check ttt.IsAlive and do ttt.Abort() and ttt = Nothing
and test.

The (worker thread) code is being called by pageclass which is also
generated by some other asp.net parent thread (if that is calling abort
or someother stuff on the thread of pageclass this could affect).

Do let us know of your proceedings.

--
hB

Thread issue/leak?

I am creating a worker thread from inside an aspx page and the thread does
the stuff it should do, no problem.
However, I have noticed running it in the debugger that it seems as if the
threads are not killed/garbage-collected after a thread terminates. I have a
breakpoint in the thread itself and every time it breaks, in the Threads
window I observe the new thread, but the previous thread is still there as
well. The exact same code in a windows app performs as expected, on every
break there are two threads, the main thread and the current worker thread.
The simplified code below also gives the same results, so nothing strange in
the thread itself. If I put the code in a loop of 2000 cycles and break
after the last, then there are 2000 worker threads displayed in the Threads
window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
ttt.ApartmentState = Threading.ApartmentState.STA
ttt.Start()
ttt.Join()
And the simple thread:
Private Sub TheThreadProc()
Dim iii As Integer = 10
End SubThis is because you are using a Single-Threaded Apartment. There is nothing
in the thread to receive messages. When you use COM in an ASP.Net
application, you create an Interop class that is disposable, and therefore,
the thread can be killed. IOW, don't use an STA thread unless you are doing
Interop.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>I am creating a worker thread from inside an aspx page and the thread does
> the stuff it should do, no problem.
> However, I have noticed running it in the debugger that it seems as if the
> threads are not killed/garbage-collected after a thread terminates. I have
> a
> breakpoint in the thread itself and every time it breaks, in the Threads
> window I observe the new thread, but the previous thread is still there as
> well. The exact same code in a windows app performs as expected, on every
> break there are two threads, the main thread and the current worker
> thread.
> The simplified code below also gives the same results, so nothing strange
> in
> the thread itself. If I put the code in a loop of 2000 cycles and break
> after the last, then there are 2000 worker threads displayed in the
> Threads
> window.
> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
> ttt.ApartmentState = Threading.ApartmentState.STA
> ttt.Start()
> ttt.Join()
> And the simple thread:
> Private Sub TheThreadProc()
> Dim iii As Integer = 10
> End Sub
>
Kevin, thanks for the response, however this is not it, I tested it without
STA before I posted the problem, same result.
The true thread is doing Interop, the simple example below is not (the
simple example produces the error/issue, with or without the STA statement).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
> This is because you are using a Single-Threaded Apartment. There is
> nothing in the thread to receive messages. When you use COM in an ASP.Net
> application, you create an Interop class that is disposable, and
> therefore, the thread can be killed. IOW, don't use an STA thread unless
> you are doing Interop.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Everybody picks their nose,
> But some people are better at hiding it.
> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>
Are you setting the "aspcompat" attribute?
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>
Also, Chris, as you didn't post your actual code, I can't really guess what
the problem is. However, I believe you can find your answers at one or more
of the following MSDN articles (and related links):
http://msdn.microsoft.com/library/e...
me=true
http://msdn.microsoft.com/library/e...br />
ame=true
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>
worker threads should be terminated, as you showed code of one
statement.
There would be 2000 (caller) main threads waiting for worker to be
terminated.
If you are saying worker thread (small one statement proc) is not
terminating (GC)
then Caller threads must also be alive.
Check ttt.IsAlive and do ttt.Abort() and ttt = Nothing
and test.
The (worker thread) code is being called by pageclass which is also
generated by some other asp.net parent thread (if that is calling abort
or someother stuff on the thread of pageclass this could affect).
Do let us know of your proceedings.
hB

Tuesday, March 13, 2012

Thread was being aborted exception in user control

I have an .ascx user control for creating dynamic charts from a datatable, which uses an external .aspx page for rendering the chart as a .png image. The control is not functioning as expected (ie. the chart image is not being saved in the specified folder), with the containing page catching a "Thread was being aborted" exception. The containing page itself is rendered correctly, and there is no further use of Response.Redirect or Server.Transfer after the page is loaded. Could the exception arise from the statement within the code behind file of the control where the control's image source is set:
imgGDI.imageURL = "somepage.apsx"
or is the only source likely to be the previous Server.Transfer call to the containing page? I have read other threads regarding the 'Thread was being aborted' exception and Try...Catch blocks, but the solutions detailed do not seem to have any effect.
Any suggestions most welcome.The Thread being aborted exception is the natural generation of a Server.Transfer or Response.Redirect. However a Reponse.Redirect has an option to supress the exception. Response.Redirect("foo.aspx", false);
We're using Server.Transfer("foo.aspx", false). The problem seems to be intermittant at the moment though, which is why I thought the problem may be to do with the external .aspx pages being used for the image source.