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

S

Shashank

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());
}
}
}
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top