• Welcome to ForumKorner!
    Join today and become a part of the community.

C# Error

Status
Not open for further replies.

Krish

User is banned.
Reputation
0
Closed thread, @Coder's helping me get it resolved, thanks <3
 

Coder

Power member.
Reputation
0
Change.. "NotFound" to "ProtocolError".

Let me know if that works.
 

Krish

User is banned.
Reputation
0
Coder said:
Change.. "NotFound" to "ProtocolError".

Let me know if that works.

Just changed and it added another error.
WyFGbNm.png
 

jjjjj

Active Member
Reputation
0
I don't use C# so I may be wrong but wouldn't you want to be calling the status code on your response variable?

so if (response.StatusCode == HttpStatusCode.NotFound)
 

Krish

User is banned.
Reputation
0
EGLZ said:
I don't use C# so I may be wrong but wouldn't you want to be calling the status code on your response variable?

so if (response.StatusCode == HttpStatusCode.NotFound)

Just tried, response doesn't have the definition for .StatusCode, when i try just response, it can't be applied to opperands of type 'System.Net.WebResponse' and 'System.Net.HttpStatusCode'
 

Coder

Power member.
Reputation
0
Try this.. don't hold me to it though. I had to use a converter as I don't know C# that well. I feel like this will work though.

Code:
WebResponse response = request.GetResponse();
               Stream dataStream = response.GetResponseStream();
               StreamReader reader = new StreamReader(dataStream);
               string responseFromServer = reader.ReadToEnd();
               //Console.WriteLine(responseFromServer);
               reader.Close();
               response.Close();
               try
               {
                   response = request.GetResponse() as HttpWebResponse;
               }              
catch (WebException ex)
               {                  

if (ex.Status == WebExceptionStatus.ProtocolError)
{
     Available.Items.Add(all.SelectedIndex);
      st.Text = ("Fk Is Beast: " + all.SelectedItem);
}
}
 

Krish

User is banned.
Reputation
0
Coder said:
Try this.. don't hold me to it though. I had to use a converter as I don't know C# that well. I feel like this will work though.
Code:
WebResponse response = request.GetResponse();
              Stream dataStream = response.GetResponseStream();
              StreamReader reader = new StreamReader(dataStream);
              string responseFromServer = reader.ReadToEnd();
              //Console.WriteLine(responseFromServer);
              reader.Close();
              response.Close();
              try
              {
                  response = request.GetResponse() as HttpWebResponse;
              }              
catch (WebException ex)
              {                  
if (ex.Status == WebExceptionStatus.ProtocolError)
{
    Available.Items.Add(all.SelectedIndex);
     st.Text = ("Fk Is Beast: " + all.SelectedItem);
}
}
NICE! It works but doesn't move the item into the listbox at the end, this bit doesn't work and i haven't gotten it to work yet:
Code:
 if (ex.Status != WebExceptionStatus.ProtocolError)
{
Available.Items.Add(all.SelectedItem);
     st.Text = ("Fk Is Beast: " + all.SelectedItem);
}
 

Coder

Power member.
Reputation
0
Krish said:
NICE! It works but doesn't move the item into the listbox at the end, this bit doesn't work and i haven't gotten it to work yet:


Code:
                    if (ex.Status != WebExceptionStatus.ProtocolError)
                    {
                        Available.Items.Add(all.SelectedItem);
                        st.Text = ("Checker: " + all.SelectedItem);
                    }
Can you give some more detail on how your looping function works?

Are you using a for each loop? Can you show a the beginning part of your code? (you can censor out the API/URL if you want)
 

Krish

User is banned.
Reputation
0
Coder said:
Can you give some more detail on how your looping function works?

Are you using a for each loop? Can you show a the beginning part of your code? (you can censor out the API/URL if you want)

I'll PM you what I got so far as far as my Checking Method.
 

Coder

Power member.
Reputation
0
Krish said:
I'll PM you what I got so far as far as my Checking Method.

Alright, I'll see if I can help you get the listbox issue working. 
 
Status
Not open for further replies.
Top