CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by bmFzYXlvbw » Thu, 04 Sep 2008 11:27:00 GMT

I make a HttpWebRequest to the web which is hosted in the local host from my
C# application by the following code:


HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://localhost:1035/Web/LogIn.aspx");

But every time I start the server the port no is changing which makes
changes to the above code. How can I get rid of it. Can't I make the request
without specifiying the port no? How can I make the above string independent
from the server port no?

Thanks in advance

Hope to see an answer soon.





CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by Peter Duniho » Thu, 04 Sep 2008 12:15:35 GMT


On Wed, 03 Sep 2008 20:27:00 -0700, nasayoo



Yes, but the server has to be on the standard HTTP port, 80.


Configure your server so that it always uses the standard HTTP port: 80.

Pete

CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by bmFzYXlvbw » Thu, 04 Sep 2008 12:22:01 GMT

> Configure your server so that it always uses the standard HTTP port: 80.
How to cofigure the server??

CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by Peter Duniho » Thu, 04 Sep 2008 12:42:22 GMT

On Wed, 03 Sep 2008 21:22:01 -0700, nasayoo



Impossible to answer without knowing how you've implemented the server.
Most HTTP servers would default to port 80 on their own. You obviously
have an exception to that rule. But beyond that, you haven't shared any
details that would help us answer.

CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by bmFzYXlvbw » Thu, 04 Sep 2008 12:53:01 GMT

As a simple way, I just edited the solution file of my webproject like below,
VWDPort = "80"
Now when I run the project, its running on the localhost - port 80. But I
have a doubt whether this change is permanent or not.
Btw: when I deploy it(I am going to deploy it in another machine), will it
change?

CSharp/C# >> How to make a HttpWebRequest without specifying the port no?

by Pavel Minaev » Thu, 04 Sep 2008 13:11:47 GMT


When you deploy it, you won't be using the VSW embedded testing Web server,
obviously. So it will depend on the way the production Web server you're
deploying it to is configured.

Similar Threads

1. Making all threads in an AppDomain of a specified Culture

Hi,

My application creates a number of aync threads....i want to make sure that 
all these threads are of the invariant culture. So, how do i ensure that 
whenever a new thread is created in my appdomain, it is of this culture?

Thanks in advance,
A G Benny

2. Specify port

3. [OT] Specify port no to connect to Informix Database through ODBC

"Lee" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> Hi,
> I'm developing a socket program to connect to Informix database
> through the ODBC. In here i called my socket program as "tap" . My tap
> will listen for data from unix through port 1070. After checking of
> the data, tap will then insert the data to the informix database. I
> know we can point the tap to one specified port in Informix database
> through the services file. My question is how should i know to which
> port my tap program send out to the informix database or should i ask
> how should i specify one port to connect to the informix and lock that
> port from other process to use it?For current moment, my tap will
> randomly pick one port to connect to informix database.

Try as I might, I cannot find a single question or comment about
C++ in your post.

Perhaps you meant to post to an "Informix" and/or "ODBC" newsgroup?

-Mike


4. Open Specified Port

5. Specify port no to connect to Informix Database through ODBC

Hi,
I'm developing a socket program to connect to Informix database
through the ODBC. In here i called my socket program as "tap" . My tap
will listen for data from unix through port 1070. After checking of
the data, tap will then insert the data to the informix database. I
know we can point the tap to one specified port in Informix database
through the services file. My question is how should i know to which
port my tap program send out to the informix database or should i ask
how should i specify one port to connect to the informix and lock that
port from other process to use it?For current moment, my tap will
randomly pick one port to connect to informix database.

My coding for connect to Informix looks like below;
// Initialize ODBC variables
// NOTE : Make sure these variables is intialized before used.
henv = SQL_NULL_HENV;
hdbc = SQL_NULL_HDBC;
hstmt = hOrderStmt = hTradeStmt = SQL_NULL_HSTMT;

SQLAllocEnv(&henv);
SQLAllocConnect(henv, &hdbc);

char szRetMsg[500];
memset(szRetMsg, '\0', sizeof(szRetMsg));
	
if (SQLSetConnectOption(hdbc,SQL_TXN_ISOLATION,SQL_TXN_READ_UNCOMMITTED)
!= SQL_SUCCESS)	{
       SQLErrorMessageBox(henv,hdbc,hstmt,"Connect",(LPSTR)&szRetMsg);
       ::MessageBox(NULL,szRetMsg,"Tap32",MB_ICONSTOP|MB_TASKMODAL);
       PostQuitMessage(0);
       return FALSE;
}


if (SQLConnect(hdbc, szDSN, SQL_NTS, szUserID, SQL_NTS, szPassword,
SQL_NTS) != SQL_SUCCESS)
{
	SQLErrorMessageBox(henv,hdbc,hstmt,"Connect",(LPSTR)&szRetMsg);
	::MessageBox(NULL,szRetMsg,"Tap32",MB_ICONSTOP|MB_TASKMODAL);
	PostQuitMessage(0);
	return FALSE;
}

I really appreciate if someone can help me out. Thank you very much.

6. Can we Encrypt a message with RSAPKCSFormatter without specifying a private key - CSharp/C#

7. Specifying platform independent interface without using virtual member functions

Hi!
As you know, one way to seperate platform dependent code from platform
_independent_ code is to create an abstract base class which acts as an
interface towards all platform independent code and implement platform
specific code in the sub classes. Since the platform (in most cases I
quess :) ) can't vary during the execution of a program, using virtual
functions to specify the interface seams a bit odd. I'm thinking about
using templates instead in something like the following way.

template<class Impl>
class GenericSocket
{
//Interface
private:
  Impl m_impl;
};

class Win32Impl
{
};

class UNIXImpl
{
};

#if defined WIN32
typedef GenericSocket<Win32Imp> Socket;
...
#endif

One downside of this approach is that the interface that must be
implemented by an implementation class isn't specified (at least not
fully) through the interface of GenericSocket which it would be when
using an abstract base class instead.

Any thoughts on this matter? How do you do it?

Regards
M

8. specifying interface without definition?