Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Wednesday, March 28, 2012

TableAdapters and web.config

I have a class library that contains a number of TableAdapters and I'm using
this from a web application. Is there a way of getting the TableAdapters to
use the connectionstrings defined in web.config.

From the MSDN documentation it seems like it's possible to override settings
with values in a config file for winform applications. Is the same possible
for web applications.

I have tried to add a connectionstring (under the connectionstring section)
in web.config with the same name as the name in the setting file. The
connectionstring in web.config points to a database that doesn't contain the
required schema. Since I'm not getting any errors and things are still
working, I assume it is still using the default connectionstring supplied at
designtime.Hi Kimbell,

Welcome to ASP.NET newsgroup.
Regarding on the configuration issue you mentioned when using TableAdapter
from class library in asp.net 2.0 project, I've also met this problem
before. Yes, as you has mentioned, when we has build the
DataSet/TableAdapter in class library project, the TableAdapter's
Connection /ConnectionString setting is persisted in the classlibrary
assembly's content so that when referenced in asp.net 2.0 project, it won't
use the web.config file's info (but still use the one persisted at
design-time in classlibrary project). Based on my research, as for the
Project Settings, the asp.net 2.0 seems has different support from winform
project. Currently one approach is manually modify the TableAdapter's
design-time generated code in the Classlibrary project. for example:

the TAbleAdapter's autogenerate code is as below, the "InitConnection"
function is just the one which supply connectionstring and constructing the
Connection instance for the TableAdapter

=============================
private void InitConnection()
{
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString =
DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
}

which retrieve the connection string through Project's Properties.Settings
collection. We can modify it to the following one:

======================

Object obj =
System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
ConnectionStringsSection css = obj as ConnectionStringsSection;
string connstr =
css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString = connstr;

=====================

so that it will retrieve the info from the final hosting application's
application config file (appconfig or web.config).

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security

-------
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXNckyfTDC6JTskQe231gX8p+7Y9A==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "=?Utf-8?B?Q2hyaXN0b3BoZXIgS2ltYmVsbA==?="
<c_kimbell@.newsgroup.nospam>
| Subject: TableAdapters and web.config
| Date: Mon, 10 Oct 2005 01:12:04 -0700
| Lines: 15
| Message-ID: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349611
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I have a class library that contains a number of TableAdapters and I'm
using
| this from a web application. Is there a way of getting the TableAdapters
to
| use the connectionstrings defined in web.config.
|
| From the MSDN documentation it seems like it's possible to override
settings
| with values in a config file for winform applications. Is the same
possible
| for web applications.
|
| I have tried to add a connectionstring (under the connectionstring
section)
| in web.config with the same name as the name in the setting file. The
| connectionstring in web.config points to a database that doesn't contain
the
| required schema. Since I'm not getting any errors and things are still
| working, I assume it is still using the default connectionstring supplied
at
| designtime.
|
|
So what you are recommending is to change the autogenerated code?
What about the following warning at the top of the file:

"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."

Particularly the statement about lost changes.

I think a better approach is to change the ConnectionModifier to public in
the designer; then set the connectionstring from code.

I was hoping for a more elegant solution since Microsoft has put some work
into this settings system. Maybe in the next version.

"Steven Cheng[MSFT]" wrote:

> Hi Kimbell,
> Welcome to ASP.NET newsgroup.
> Regarding on the configuration issue you mentioned when using TableAdapter
> from class library in asp.net 2.0 project, I've also met this problem
> before. Yes, as you has mentioned, when we has build the
> DataSet/TableAdapter in class library project, the TableAdapter's
> Connection /ConnectionString setting is persisted in the classlibrary
> assembly's content so that when referenced in asp.net 2.0 project, it won't
> use the web.config file's info (but still use the one persisted at
> design-time in classlibrary project). Based on my research, as for the
> Project Settings, the asp.net 2.0 seems has different support from winform
> project. Currently one approach is manually modify the TableAdapter's
> design-time generated code in the Classlibrary project. for example:
> the TAbleAdapter's autogenerate code is as below, the "InitConnection"
> function is just the one which supply connectionstring and constructing the
> Connection instance for the TableAdapter
> =============================
> private void InitConnection()
> {
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString =
> DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
> }
> which retrieve the connection string through Project's Properties.Settings
> collection. We can modify it to the following one:
> ======================
> Object obj =
> System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
> ConnectionStringsSection css = obj as ConnectionStringsSection;
> string connstr =
> css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString = connstr;
> =====================
> so that it will retrieve the info from the final hosting application's
> application config file (appconfig or web.config).
> Hope helps. Thanks,
> Steven Cheng
> Microsoft Online Support
Thanks for your response Kimbell,

Yes, the
========
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
========
you mentioned is really a potential problem with my workaround. And your
appoarch on changing the ConnectionModifer to public is OK for
programmatical accessing. However, in most cases of ASP.NET 2.0 web
application, we will use design-time ObjectDataSource control to reference
the TableAdpater, and this is done through IDE interactively no code is
involved. So in such scenario, we may need to predefined the connection's
initilization in TableAdapter's code.

Anyway, I really appreciate your advice on the configuration setttings ,
and since this is a new feature involved in 2.0, I think it'll be improved
in the sequential versions so as to ease the component, class library
developing and seamless integrated into
front end applications.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
-------
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXOO+CVs5sRlZYtRh+M2u+nQzNUBg==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "=?Utf-8?B?Q2hyaXN0b3BoZXIgS2ltYmVsbA==?="
<c_kimbell@.newsgroup.nospam>
| References: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
<o4v8pDhzFHA.3712@.TK2MSFTNGXA02.phx.gbl>
| Subject: RE: TableAdapters and web.config
| Date: Tue, 11 Oct 2005 01:15:01 -0700
| Lines: 68
| Message-ID: <EAC2EB76-0E98-4837-AD33-55A57F82A6EA@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349877
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So what you are recommending is to change the autogenerated code?
| What about the following warning at the top of the file:
|
| "Changes to this file may cause incorrect behavior and will be lost if
the
| code is regenerated."
|
| Particularly the statement about lost changes.
|
| I think a better approach is to change the ConnectionModifier to public
in
| the designer; then set the connectionstring from code.
|
| I was hoping for a more elegant solution since Microsoft has put some
work
| into this settings system. Maybe in the next version.
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Kimbell,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the configuration issue you mentioned when using
TableAdapter
| > from class library in asp.net 2.0 project, I've also met this problem
| > before. Yes, as you has mentioned, when we has build the
| > DataSet/TableAdapter in class library project, the TableAdapter's
| > Connection /ConnectionString setting is persisted in the classlibrary
| > assembly's content so that when referenced in asp.net 2.0 project, it
won't
| > use the web.config file's info (but still use the one persisted at
| > design-time in classlibrary project). Based on my research, as for the
| > Project Settings, the asp.net 2.0 seems has different support from
winform
| > project. Currently one approach is manually modify the TableAdapter's
| > design-time generated code in the Classlibrary project. for example:
| >
| > the TAbleAdapter's autogenerate code is as below, the "InitConnection"
| > function is just the one which supply connectionstring and constructing
the
| > Connection instance for the TableAdapter
| >
| > =============================
| > private void InitConnection()
| > {
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString =
| > DSLibrary.Properties.Settings.Default.NorthwindCon nectionString;
| > }
| >
| > which retrieve the connection string through Project's
Properties.Settings
| > collection. We can modify it to the following one:
| >
| > ======================
| >
| > Object obj =
| >
System.Configuration.ConfigurationSettings.GetConf ig("connectionStrings");
| > ConnectionStringsSection css = obj as ConnectionStringsSection;
| > string connstr =
| > css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString = connstr;
| >
| > =====================
| >
| > so that it will retrieve the info from the final hosting application's
| > application config file (appconfig or web.config).
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
|
|

TableAdapters and web.config

I have a class library that contains a number of TableAdapters and I'm using
this from a web application. Is there a way of getting the TableAdapters to
use the connectionstrings defined in web.config.
From the MSDN documentation it seems like it's possible to override settings
with values in a config file for winform applications. Is the same possible
for web applications.
I have tried to add a connectionstring (under the connectionstring section)
in web.config with the same name as the name in the setting file. The
connectionstring in web.config points to a database that doesn't contain the
required schema. Since I'm not getting any errors and things are still
working, I assume it is still using the default connectionstring supplied at
designtime.Hi Kimbell,
Welcome to ASP.NET newsgroup.
Regarding on the configuration issue you mentioned when using TableAdapter
from class library in asp.net 2.0 project, I've also met this problem
before. Yes, as you has mentioned, when we has build the
DataSet/TableAdapter in class library project, the TableAdapter's
Connection /ConnectionString setting is persisted in the classlibrary
assembly's content so that when referenced in asp.net 2.0 project, it won't
use the web.config file's info (but still use the one persisted at
design-time in classlibrary project). Based on my research, as for the
Project Settings, the asp.net 2.0 seems has different support from winform
project. Currently one approach is manually modify the TableAdapter's
design-time generated code in the Classlibrary project. for example:
the TAbleAdapter's autogenerate code is as below, the "InitConnection"
function is just the one which supply connectionstring and constructing the
Connection instance for the TableAdapter
=============================
private void InitConnection()
{
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString =
DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
}
which retrieve the connection string through Project's Properties.Settings
collection. We can modify it to the following one:
======================
Object obj =
System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
ConnectionStringsSection css = obj as ConnectionStringsSection;
string connstr =
css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
this.m_connection = new System.Data.SqlClient.SqlConnection();
this.m_connection.ConnectionString = connstr;
=====================
so that it will retrieve the info from the final hosting application's
application config file (appconfig or web.config).
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXNckyfTDC6JTskQe231gX8p+7Y9A==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "examnotes"
<c_kimbell@.newsgroup.nospam>
| Subject: TableAdapters and web.config
| Date: Mon, 10 Oct 2005 01:12:04 -0700
| Lines: 15
| Message-ID: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349611
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I have a class library that contains a number of TableAdapters and I'm
using
| this from a web application. Is there a way of getting the TableAdapters
to
| use the connectionstrings defined in web.config.
|
| From the MSDN documentation it seems like it's possible to override
settings
| with values in a config file for winform applications. Is the same
possible
| for web applications.
|
| I have tried to add a connectionstring (under the connectionstring
section)
| in web.config with the same name as the name in the setting file. The
| connectionstring in web.config points to a database that doesn't contain
the
| required schema. Since I'm not getting any errors and things are still
| working, I assume it is still using the default connectionstring supplied
at
| designtime.
|
|
So what you are recommending is to change the autogenerated code?
What about the following warning at the top of the file:
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
Particularly the statement about lost changes.
I think a better approach is to change the ConnectionModifier to public in
the designer; then set the connectionstring from code.
I was hoping for a more elegant solution since Microsoft has put some work
into this settings system. Maybe in the next version.
"Steven Cheng[MSFT]" wrote:

> Hi Kimbell,
> Welcome to ASP.NET newsgroup.
> Regarding on the configuration issue you mentioned when using TableAdapter
> from class library in asp.net 2.0 project, I've also met this problem
> before. Yes, as you has mentioned, when we has build the
> DataSet/TableAdapter in class library project, the TableAdapter's
> Connection /ConnectionString setting is persisted in the classlibrary
> assembly's content so that when referenced in asp.net 2.0 project, it won'
t
> use the web.config file's info (but still use the one persisted at
> design-time in classlibrary project). Based on my research, as for the
> Project Settings, the asp.net 2.0 seems has different support from winform
> project. Currently one approach is manually modify the TableAdapter's
> design-time generated code in the Classlibrary project. for example:
> the TAbleAdapter's autogenerate code is as below, the "InitConnection"
> function is just the one which supply connectionstring and constructing th
e
> Connection instance for the TableAdapter
> =============================
> private void InitConnection()
> {
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString =
> DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
> }
> which retrieve the connection string through Project's Properties.Setting
s
> collection. We can modify it to the following one:
> ======================
> Object obj =
> System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
> ConnectionStringsSection css = obj as ConnectionStringsSection;
> string connstr =
> css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
> this.m_connection = new System.Data.SqlClient.SqlConnection();
> this.m_connection.ConnectionString = connstr;
> =====================
> so that it will retrieve the info from the final hosting application's
> application config file (appconfig or web.config).
> Hope helps. Thanks,
> Steven Cheng
> Microsoft Online Support
>
Thanks for your response Kimbell,
Yes, the
========
"Changes to this file may cause incorrect behavior and will be lost if the
code is regenerated."
========
you mentioned is really a potential problem with my workaround. And your
appoarch on changing the ConnectionModifer to public is OK for
programmatical accessing. However, in most cases of ASP.NET 2.0 web
application, we will use design-time ObjectDataSource control to reference
the TableAdpater, and this is done through IDE interactively no code is
involved. So in such scenario, we may need to predefined the connection's
initilization in TableAdapter's code.
Anyway, I really appreciate your advice on the configuration setttings ,
and since this is a new feature involved in 2.0, I think it'll be improved
in the sequential versions so as to ease the component, class library
developing and seamless integrated into
front end applications.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
--
| Thread-Topic: TableAdapters and web.config
| thread-index: AcXOO+CVs5sRlZYtRh+M2u+nQzNUBg==
| X-WBNR-Posting-Host: 195.139.24.170
| From: "examnotes"
<c_kimbell@.newsgroup.nospam>
| References: <69C48290-408C-4942-9F61-3C909A6766E3@.microsoft.com>
<o4v8pDhzFHA.3712@.TK2MSFTNGXA02.phx.gbl>
| Subject: RE: TableAdapters and web.config
| Date: Tue, 11 Oct 2005 01:15:01 -0700
| Lines: 68
| Message-ID: <EAC2EB76-0E98-4837-AD33-55A57F82A6EA@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349877
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| So what you are recommending is to change the autogenerated code?
| What about the following warning at the top of the file:
|
| "Changes to this file may cause incorrect behavior and will be lost if
the
| code is regenerated."
|
| Particularly the statement about lost changes.
|
| I think a better approach is to change the ConnectionModifier to public
in
| the designer; then set the connectionstring from code.
|
| I was hoping for a more elegant solution since Microsoft has put some
work
| into this settings system. Maybe in the next version.
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Kimbell,
| >
| > Welcome to ASP.NET newsgroup.
| > Regarding on the configuration issue you mentioned when using
TableAdapter
| > from class library in asp.net 2.0 project, I've also met this problem
| > before. Yes, as you has mentioned, when we has build the
| > DataSet/TableAdapter in class library project, the TableAdapter's
| > Connection /ConnectionString setting is persisted in the classlibrary
| > assembly's content so that when referenced in asp.net 2.0 project, it
won't
| > use the web.config file's info (but still use the one persisted at
| > design-time in classlibrary project). Based on my research, as for the
| > Project Settings, the asp.net 2.0 seems has different support from
winform
| > project. Currently one approach is manually modify the TableAdapter's
| > design-time generated code in the Classlibrary project. for example:
| >
| > the TAbleAdapter's autogenerate code is as below, the "InitConnection"
| > function is just the one which supply connectionstring and constructing
the
| > Connection instance for the TableAdapter
| >
| > =============================
| > private void InitConnection()
| > {
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString =
| > DSLibrary.Properties.Settings.Default.NorthwindConnectionString;
| > }
| >
| > which retrieve the connection string through Project's
Properties.Settings
| > collection. We can modify it to the following one:
| >
| > ======================
| >
| > Object obj =
| >
System.Configuration.ConfigurationSettings.GetConfig("connectionStrings");
| > ConnectionStringsSection css = obj as ConnectionStringsSection;
| > string connstr =
| > css.ConnectionStrings["LocalNorthwindConnStr"].ConnectionString;
| > this.m_connection = new System.Data.SqlClient.SqlConnection();
| > this.m_connection.ConnectionString = connstr;
| >
| > =====================
| >
| > so that it will retrieve the info from the final hosting application's
| > application config file (appconfig or web.config).
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
|
|

Tuesday, March 13, 2012

TCPClient connect slow only on XP Pro ASP on some boxes

I have an ASP.NET app that has very slow connect times using TCPClient, or
the Socket class, or even calling a COM object that uses C socket calls on
certain similar XP SP2 boxes.

On those boxes, if another connection is made within a couple seconds, it is
fast. Running the same C# code in a console app connects instantly.
Unplugging the network cable allows localhost connections to be instant (?!).

Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant, so
it comes down to being ASP.NET on XP Pro on certain boxes. I've includes the
test results and programs. The boxes with the problems are laptops. Is it
an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is greatly
appreciated.

Jim W

Test results:
XPPro ASP to Remote server
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Med sleep 2 took 0 seconds

XPPro ASP to Localhost with network connection
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Mec sleep 2 took 4 seconds

XPPro ASP to Localhost unplugged
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

XPPro .NET console app to localhost, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

W2K Server to local host, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

Pertinent ASP.NET code behind:
...
private void RunTests_Click(object sender, System.EventArgs e)
{
Output.Text = Tester.RunTests( HostName.Text, "<br>" );
}

Pertinent .NET console app code.
...
static void Main(string[] args)
{
System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
}

The tester called by ASP.NET and a .NET console app:

using System;
using System.Net;
using System.Net.Sockets;

namespace SocketTest
{
public class Tester
{
public Tester() {}

public static string RunTests( string server, string eol )
{
string ret = RunTest( server, "First ", eol );

System.Threading.Thread.Sleep( 100 );

ret += RunTest( server, "Short sleep 1", eol );

System.Threading.Thread.Sleep( 100 );

ret += RunTest( server, "Short sleep 2", eol );

System.Threading.Thread.Sleep( 10000 );

ret += RunTest( server, "Long sleep 1", eol );

System.Threading.Thread.Sleep( 5000 );

ret += RunTest( server, "Med sleep 2", eol );

return ret;
}

static string RunTest( string server, string prefix, string eol )
{
DateTime start = DateTime.Now;
TcpClient conn = new TcpClient( server, 80 );
TimeSpan span = DateTime.Now - start;
conn.Close();

return prefix + " took " + span.Seconds + " seconds " + eol;
}
}
}most likely you proxy server setting don't exclude localhost.

-- bruce (sqlwork.com)

"Jim W" <JimW@.discussions.microsoft.com> wrote in message
news:5F733251-4CAF-4EF9-98AA-0CA14F103854@.microsoft.com...
> I have an ASP.NET app that has very slow connect times using TCPClient, or
> the Socket class, or even calling a COM object that uses C socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple seconds, it
is
> fast. Running the same C# code in a console app connects instantly.
> Unplugging the network cable allows localhost connections to be instant
(?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant,
so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes
the
> test results and programs. The boxes with the problems are laptops. Is
it
> an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is
greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, string eol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " + eol;
> }
> }
> }
Tx for the reply. I can't find any IIS proxy settings, can you give some
details? I'm not using a proxy in the IE settings. I did try turning the
proxy on, and excluded localhost, and it still is slow.

"bruce barker" wrote:

> most likely you proxy server setting don't exclude localhost.
> -- bruce (sqlwork.com)
New information. The slow computers have a gigbit network and wireless. If
the network cable is attached, *and* wireless is connected, the connect time
goes from 6 seconds (with just the network) to 27 seconds!
Jim,

We're experiencing (in a somewhat different context) the exactsame problem. We're as clueless as you seem to be. I can'treally relate to the suggestion that your proxy settings mighthave something to do with it, but who knows. Have you made anyprogress towards resolution since you posted your question?

Andre

> I have an ASP.NET app that has very slow connect times usingTCPClient, or
> the Socket class, or even calling a COM object that uses Csocket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a coupleseconds, it is
> fast. Running the same C# code in a console app connectsinstantly.
> Unplugging the network cable allows localhost connections to beinstant (?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 boxis instant, so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes the
> test results and programs. The boxes with the problems arelaptops. Is it
> an ASP.NET config issue? XP SP2 Security issue? Anyideas/help is greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0],"\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
>
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
>
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
>
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
>
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, stringeol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " +eol;
> }
> }
> }
User submitted from AEWNET (http://www.aewnet.com/)
No, I haven't found a solution. On the production machines, which are not
multihomed, it is not an issue, but it's on my todo list.

I will post if I find a solution. Please post if you find one.

"Andre de Lange" wrote:

> Jim,
> We're experiencing (in a somewhat different context) the exact same problem. We're as clueless as you seem to be. I can't really relate to the suggestion that your proxy settings might have something to do with it, but who knows. Have you made any progress towards resolution since you posted your question?
> Andre

TCPClient connect slow only on XP Pro ASP on some boxes

I have an ASP.NET app that has very slow connect times using TCPClient, or
the Socket class, or even calling a COM object that uses C socket calls on
certain similar XP SP2 boxes.
On those boxes, if another connection is made within a couple seconds, it is
fast. Running the same C# code in a console app connects instantly.
Unplugging the network cable allows localhost connections to be instant (?!)
.
Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant, so
it comes down to being ASP.NET on XP Pro on certain boxes. I've includes th
e
test results and programs. The boxes with the problems are laptops. Is it
an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is greatly
appreciated.
Jim W
Test results:
XPPro ASP to Remote server
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Med sleep 2 took 0 seconds
XPPro ASP to Localhost with network connection
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Mec sleep 2 took 4 seconds
XPPro ASP to Localhost unplugged
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
XPPro .NET console app to localhost, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
W2K Server to local host, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
Pertinent ASP.NET code behind:
...
private void RunTests_Click(object sender, System.EventArgs e)
{
Output.Text = Tester.RunTests( HostName.Text, "<br>" );
}
Pertinent .NET console app code.
...
static void Main(string[] args)
{
System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
}
The tester called by ASP.NET and a .NET console app:
using System;
using System.Net;
using System.Net.Sockets;
namespace SocketTest
{
public class Tester
{
public Tester() {}
public static string RunTests( string server, string eol )
{
string ret = RunTest( server, "First ", eol );
System.Threading.Thread.Sleep( 100 );
ret += RunTest( server, "Short sleep 1", eol );
System.Threading.Thread.Sleep( 100 );
ret += RunTest( server, "Short sleep 2", eol );
System.Threading.Thread.Sleep( 10000 );
ret += RunTest( server, "Long sleep 1", eol );
System.Threading.Thread.Sleep( 5000 );
ret += RunTest( server, "Med sleep 2", eol );
return ret;
}
static string RunTest( string server, string prefix, string eol )
{
DateTime start = DateTime.Now;
TcpClient conn = new TcpClient( server, 80 );
TimeSpan span = DateTime.Now - start;
conn.Close();
return prefix + " took " + span.Seconds + " seconds " + eol;
}
}
}most likely you proxy server setting don't exclude localhost.
-- bruce (sqlwork.com)
"Jim W" <JimW@.discussions.microsoft.com> wrote in message
news:5F733251-4CAF-4EF9-98AA-0CA14F103854@.microsoft.com...
> I have an ASP.NET app that has very slow connect times using TCPClient, or
> the Socket class, or even calling a COM object that uses C socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple seconds, it
is
> fast. Running the same C# code in a console app connects instantly.
> Unplugging the network cable allows localhost connections to be instant
(?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant,
so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes
the
> test results and programs. The boxes with the problems are laptops. Is
it
> an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is
greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, string eol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " + eol;
> }
> }
> }
>
Tx for the reply. I can't find any IIS proxy settings, can you give some
details? I'm not using a proxy in the IE settings. I did try turning the
proxy on, and excluded localhost, and it still is slow.
"bruce barker" wrote:

> most likely you proxy server setting don't exclude localhost.
> -- bruce (sqlwork.com)
>
New information. The slow computers have a gigbit network and wireless. If
the network cable is attached, *and* wireless is connected, the connect time
goes from 6 seconds (with just the network) to 27 seconds!
Jim,
We're experiencing (in a somewhat different context) the exact=
same problem. We're as clueless as you seem to be. I can't=
really relate to the suggestion that your proxy settings might=
have something to do with it, but who knows. Have you made any=
progress towards resolution since you posted your question?
Andre

> I have an ASP.NET app that has very slow connect times using=
TCPClient, or
> the Socket class, or even calling a COM object that uses C=
socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple=
seconds, it is
> fast. Running the same C# code in a console app connects=
instantly.
> Unplugging the network cable allows localhost connections to be=
instant (?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box=
is instant, so
> it comes down to being ASP.NET on XP Pro on certain boxes. =
I've includes the
> test results and programs. The boxes with the problems are=
laptops. Is it
> an ASP.NET config issue? XP SP2 Security issue? Any=
ideas/help is greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds =09
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> =09Output.Text =3D Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> =09System.Console.WriteLine( SocketTest.Tester.RunTests( args[0],=
"\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> =09public class Tester
> =09{
> =09=09public Tester() {}
> =09=09public static string RunTests( string server, string eol )
> =09=09{
> =09=09=09string ret =3D RunTest( server, "First ", eol );
> =09=09=09System.Threading.Thread.Sleep( 100 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Short sleep 1", eol );
> =09=09=09System.Threading.Thread.Sleep( 100 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Short sleep 2", eol );
> =09=09=09System.Threading.Thread.Sleep( 10000 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Long sleep 1", eol );
> =09=09=09System.Threading.Thread.Sleep( 5000 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Med sleep 2", eol );
> =09=09=09return ret;
> =09=09}
> =09=09static string RunTest( string server, string prefix, string=
eol )
> =09=09{
> =09=09=09DateTime start =3D DateTime.Now;
> =09=09=09TcpClient conn =3D new TcpClient( server, 80 );
> =09=09=09TimeSpan span =3D DateTime.Now - start;
> =09=09=09conn.Close();
> =09=09=09return prefix + " took " + span.Seconds + " seconds " +=
eol;
> =09=09}
> =09}
> }
>
User submitted from AEWNET (http://www.aewnet.com/)
No, I haven't found a solution. On the production machines, which are not
multihomed, it is not an issue, but it's on my todo list.
I will post if I find a solution. Please post if you find one.
"Andre de Lange" wrote:

> Jim,
> We're experiencing (in a somewhat different context) the exact same problem. We're
as clueless as you seem to be. I can't really relate to the suggestion that your pr
oxy settings might have something to do with it, but who knows. Have you made any pr
ogr
ess towards resolution since you posted your question?
> Andre