Hello,
I am just getting into asp.net development (have a winforms background)
I have a sockets server running on my windows 2003 machine. I made a class called ClientTcp that opens a new connection and sends a string to the server and placed this in APP_CODE.
I call ClientTcp :
public class ClientTCP{private TcpClient tcpClient;public void SendData(String toSend) { tcpClient =new TcpClient(CONNECT_ADDR, CONNECT_PORT); NetworkStream networkStream = tcpClient.GetStream(); StreamWriter streamWriter =new StreamWriter(networkStream, System.Text.Encoding.ASCII); streamWriter.WriteLine(toSend); streamWriter.Flush(); }}
From my code behind Default.aspx.cs:
ClientTCP c =new ClientTCP();c.SendData("In app_code");
This works great on my local VS 2005 debug but when this runs under IIS 6 on Windows 2003 no data is received by the socket server.
Is there some sort of permissions issue or scope issue with using a class in APP_CODE
Interesting enough if I place the SendData method directly in the Default.aspx.cs file then it opens a socket connection and sends the data.
I have looked around for clues but could not find out why the socket wont connect and send by calling a code behind.
Thanks
I have solved this isssue.
I didn't post the complete method in my earlier post. This code works correctly.
My issue was that I was attempting to build an XmlDocument and then converting that to a string and sending that string over the stream.
It seems that I cannot create an XmlDocument in memory under IIS6. Creating a temporary file and then using this may solve the real issue but I have worked around this by building a custom string builder to generate xml compliant strings.
Thanks
0 comments:
Post a Comment