473,883 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c# connecting to a web server

16 New Member
Hi

Could some one help me please, i am trying to connect c# web page version 2005 to a web server where a selection of reports reside.

Would a socket be appropiate to use, all i want to do is connect to a web server using c# and extract reports, hopefully in XML format and diaply them.

Could some one please point me in the right direction, Is there an easier way to do all this?

Thanks

Raz
Aug 10 '07 #1
7 12294
Frinavale
9,735 Recognized Expert Moderator Expert
Hi

Could some one help me please, i am trying to connect c# web page version 2005 to a web server where a selection of reports reside.

Would a socket be appropiate to use, all i want to do is connect to a web server using c# and extract reports, hopefully in XML format and diaply them.

Could some one please point me in the right direction, Is there an easier way to do all this?

Thanks

Raz
I'm not quite sure what you mean by "trying to connect a c# web page ...to a web server"

What type of application are you working on. Is it a Web Application (ASP.NET project) with C# server side code?

Why would you be considering sockets to connect to the web server?

Could you please describe the problem in more detail so that we can help you better.

Thanks

-Frinny
Aug 10 '07 #2
Plater
7,872 Recognized Expert Expert
The HttpWebRequest object might be more what you are looking for, rather just a plain old socket
Aug 10 '07 #3
ascendedguard
3 New Member
HttpWebRequest will do the trick.

If you're reading in XML, you can get a Stream object to use with System.Xml.XmlT extReader

For example, here's a piece of code i'm using to connect to an URL (specifically in the Digg API), and retrieve the results of the page (XML) in an XmlTextReader:

Expand|Select|Wrap|Line Numbers
  1.         protected static XmlTextReader GetXmlReader(String urlString)
  2.         {
  3.             System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlString);
  4.             request.UserAgent = _UserAgent;
  5.  
  6.             System.IO.StringReader myreader;
  7.  
  8.             using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9.             {
  10.                 System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
  11.  
  12.                 String results = reader.ReadToEnd();
  13.                 myreader = new System.IO.StringReader(results);
  14.             }
  15.             return new XmlTextReader(myreader);
  16.         }
  17.  
Aug 11 '07 #4
RazSam
16 New Member
Thanks ill try that when i go back into work on Monday.

HttpWebRequest will do the trick.

If you're reading in XML, you can get a Stream object to use with System.Xml.XmlT extReader

For example, here's a piece of code i'm using to connect to an URL (specifically in the Digg API), and retrieve the results of the page (XML) in an XmlTextReader:

Expand|Select|Wrap|Line Numbers
  1.         protected static XmlTextReader GetXmlReader(String urlString)
  2.         {
  3.             System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlString);
  4.             request.UserAgent = _UserAgent;
  5.  
  6.             System.IO.StringReader myreader;
  7.  
  8.             using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9.             {
  10.                 System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
  11.  
  12.                 String results = reader.ReadToEnd();
  13.                 myreader = new System.IO.StringReader(results);
  14.             }
  15.             return new XmlTextReader(myreader);
  16.         }
  17.  
Aug 12 '07 #5
RazSam
16 New Member
Hi Frinvale

I am implementing a front end ASP.NET web application page with back end c# code. My application is trying to connect to another clients web server, in order for me to extract reports (They do not have a web service in place at the moment, though they have other web services for other purposes).

At time intervals they place various reports on there server and in real time mode my application will connect and extract a report.

I was a little confussed sorry thought sockets mights work, but i guess not.

Just needed help as i am confussed. Other memebers have replied with sme good advice such as using httpwebrequest, ill try that :).

I'm not quite sure what you mean by "trying to connect a c# web page ...to a web server"

What type of application are you working on. Is it a Web Application (ASP.NET project) with C# server side code?

Why would you be considering sockets to connect to the web server?

Could you please describe the problem in more detail so that we can help you better.

Thanks

-Frinny
Aug 12 '07 #6
Frinavale
9,735 Recognized Expert Moderator Expert
Hi Frinvale

I am implementing a front end ASP.NET web application page with back end c# code. My application is trying to connect to another clients web server, in order for me to extract reports (They do not have a web service in place at the moment, though they have other web services for other purposes).

At time intervals they place various reports on there server and in real time mode my application will connect and extract a report.

I was a little confussed sorry thought sockets mights work, but i guess not.

Just needed help as i am confussed. Other memebers have replied with sme good advice such as using httpwebrequest, ill try that :).
What do you know about web services using .NET?
Have you looked them up?
Aug 13 '07 #7
RazSam
16 New Member
No i havent Frinvale, but i will look them up thanks

What do you know about web services using .NET?
Have you looked them up?
Aug 15 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3646
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on Linux, connecting to MS SQL Server, unless it was already pre-installed by your Linux installation, is to build your own multithreaded TCP socket server on Windows and connect to it through the socket API in PHP on Linux (if you have installed...
12
2807
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
3
3006
by: Ann Marinas | last post by:
Hi there, I am currently developing an ASP.NET program that connects to a SQL Server 2000 database. I also have SQL Server 2005 Express installed on the same local machine. Prior to installing SQL Server 2005, my apps were working and is connecting flawlessly to a database on the SQL Server 2000. Now, whenever I connect to the same database with the 2005 version installed, I keep on getting this error:
0
2044
by: cj.snead | last post by:
Hello, I am having trouble connecting to a remote named instance of SQL Server via Pocket PC. I have had absolutely no luck connecting with VS 2005 (even to a default instance), so I wen't back to VS .NET 2003 (I had success doing this a while back). I am trying to connect to a named instance of SQL. This is where I think my problem is. My app errors out at the Connection.Open(); command. Here is my connection string:
3
2023
by: Vinod R.Shenoy | last post by:
Hi All, Came across a post wherin you had helped somebody with a similar problem and was wondering if you could help us out with it. Our problem is , We have a development SQL Server 2000 (running on Win2K SP4) machine that we want to run on a Windows 2003 server machine and access it via our internal LAN. We have opened the firewall to allow our applications
6
7788
by: Todd Brewer | last post by:
Windows Server 2000 ASP.NET 2.0 SQL Server 2000 (on a physically seperate server) I moved an ASP.NET 2.0 application from a development server to production, and am getting the following error: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not
10
15965
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp
2
4969
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express Edition" via the link on: http://msdn2.microsoft.com/en-us/express/bb410792.aspx
2
3048
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to connect via SQL Management Studio to the database server from the application server I get the same error. Here is the error:
0
2013
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9567
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4211
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.