473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need Help! Can not read environment variables from server on http request to a html page.

Hi all,
I am a new member of this community.
I am making a http request to a html file placed on a Apache server.
On this page there is an embeded perl statement which requires
reading environment variables from the server.
When I am typing the url of the html page in my browser, I am able to
read the Environment variables from the server and getting the desired
results.
But, when I am making Http request through my window application, it
is unable to read the the environment variables.
Please help me out.

The code used is given below:
private void GetFile(string FilePath)
{
using (WebClient wcDownload = new WebClient())
{
string strFile ="test.xml";
try
{
// Code for reading the html file from the server

String downloadUrl = @"http://www.mysite/
folder_job.html";
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(downloadUrl);
webRequest.Timeout = 15000;
webRequest.Credentials =
CredentialCache.DefaultCredentials;
webResponse =
(HttpWebResponse)webRequest.GetResponse();
Int64 fileSize = webResponse.ContentLength;
strResponse = wcDownload.OpenRead(downloadUrl);

//End Code

strLocal = new FileStream(strFile,
FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
int bytesSize = 0;
byte[] downBuffer = new byte[4096];
while ((bytesSize = strResponse.Read(downBuffer,
0, downBuffer.Length)) 0)
{
strLocal.Write(downBuffer, 0, bytesSize);
}
strResponse.Close();
strLocal.Close();
webResponse.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
}
}
}

Mar 19 '07 #1
1 3111
Shashank,

I would suggest using a utility like Fiddler to intercept the request
from the browser to this url. It sounds like you probably have a cookie on
your machine for the site which the site is interpreting, and then sending
the contents back depending on that. Or it could be the user-agent header
that is causing the issue. Either way, an HTTP interceptor will help you
figure out how to craft your request to the server to get the response back
that you are looking for.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Shashank" <sh***************@gmail.comwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
Hi all,
I am a new member of this community.
I am making a http request to a html file placed on a Apache server.
On this page there is an embeded perl statement which requires
reading environment variables from the server.
When I am typing the url of the html page in my browser, I am able to
read the Environment variables from the server and getting the desired
results.
But, when I am making Http request through my window application, it
is unable to read the the environment variables.
Please help me out.

The code used is given below:
private void GetFile(string FilePath)
{
using (WebClient wcDownload = new WebClient())
{
string strFile ="test.xml";
try
{
// Code for reading the html file from the server

String downloadUrl = @"http://www.mysite/
folder_job.html";
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create(downloadUrl);
webRequest.Timeout = 15000;
webRequest.Credentials =
CredentialCache.DefaultCredentials;
webResponse =
(HttpWebResponse)webRequest.GetResponse();
Int64 fileSize = webResponse.ContentLength;
strResponse = wcDownload.OpenRead(downloadUrl);

//End Code

strLocal = new FileStream(strFile,
FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
int bytesSize = 0;
byte[] downBuffer = new byte[4096];
while ((bytesSize = strResponse.Read(downBuffer,
0, downBuffer.Length)) 0)
{
strLocal.Write(downBuffer, 0, bytesSize);
}
strResponse.Close();
strLocal.Close();
webResponse.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.ToString());
}
}
}

Mar 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its...
0
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to...
3
by: FRITSCH Vincent | last post by:
Hi, i need help on a query. I've this table : create table t ( customer number(5), time date, status varchar2(1)
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
0
by: TDM | last post by:
Hello all, I suspect I created my own problem as I had a need to install an older version of MSDN Library so now my .NET Documentation is broken. When I run : Start/All Programs/Microsoft...
0
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities,...
1
by: karizmatrix22 | last post by:
Hi, I need a programmer who can write 3 programs for following questions below.Programs need to be ready before nextweek.thank you. Person who help me these 3 questions will be get paid.. I am...
8
by: SanjaiGandhi | last post by:
Hi ...i am new to programing....pls help to overcome this program.. The Program is..: if a = 557..using for loop or while or dowhile ..we have to get the answer for 5+5+7..that is what ever...
2
by: =?Utf-8?B?am9lb2ppaA==?= | last post by:
Most students do not have enough time to do their homeworks, assignments, college papers, etc alone. Also most of them, even though they know what to do with respect to their writing assignment,...
1
by: jhaydon | last post by:
First of all, I'm not a CSS expert. If I was, I wouldn't need to be posting for help here. Secondly, I have been doing web design for several years, just not css. Thirdly, I need help and hope...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.