About Error

E

Ejder

I am writing program. it get the Source code of site.
for example; site.com/news.asp?id=55 I get the source code. But if I
try the get site.com/news.asp?id=55'a or site.com/news.asp?id=55a it
give me ERROR 500. AND the program NOT GET the Sources code. Soo in
explorer i Uncheck the SHOW FRIENDLY ERROR. so I can seee that

Microsoft OLE DB Provider for SQL Server error '80040e14'

Unclosed quotation mark before the character string 'a '.

like that. BUt in my Program I WANT to get this error Too.. In my
code. It always gooing exception.. :((


StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();

string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
Application.DoEvents();
}
while (count > 0);
resStream.Close();
response.Close();

if (File.Exists(dosya) == true) { File.Delete(dosya); }
StreamWriter writer = File.CreateText(dosya);
writer.WriteLine(sb.ToString());
writer.Close();
}
catch (Exception)
{
MessageBox.Show("Connection Failed !!"+url,"NO !!");
}
 
A

A.Kahtava

Could you post your complete source?
It sounds as though you are passing the querystring to an SQL database,
that is where your error is probably originating. SQL statements don't
like single quotes, and applications that allow them are prone to SQL
injection attacks..
If you wanted to catch the error manually you should use the 'finally'
statement.

try{
//some code
}
catch{
//some code
}
finally{
if (File.Exists(dosya) == true) { File.Delete(dosya); }
StreamWriter writer = File.CreateText(dosya);
writer.WriteLine(sb.ToString());
writer.Close();
}
 
E

Ejder

butt when I try get error . I am looking step by step.. it comes to
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
And Get response "HTTP 500 INTERNAL ERROR " and goes to CATCH BUT not
goes to under the code. Too
Stream resStream = response.GetResponseStream();

So I don'T get sources code of Site in resStream . :((
 
A

A.Kahtava

Where is your SQL statement?

The error you are recieving is due to your SQL statement, NOT your
HttpWebResponse statement.

Try googling "Microsoft OLE DB Provider for SQL Server error '80040e14'"
 
S

Steven Nagy

The reason you will be getting the error is because the site is
actually returning a 500 error when you call it with this URL:
site.com/news.asp?id=55a

This is because the parameter ID probably is expecting a numeric value.
55a is not a numeric value.
Probably whats happening on the server end of 'site.com/news.asp' is
that the server side code is collecting the value of ID and casting it
to an integer.
Of course it then throws an exception and dies, probably with a 500
error.

Try pasting your URL "site.com/news.asp?id=55a" into a web browser and
see if you get a Server Error and an equivalent error code of 500.

Essentially the problem is not with your code.

SN
 

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