[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1325
  • Last Modified:

WebRequest is returning a The remote server returned an error: (500) Internal Server Error

I'm using a public web server http://www.arvixe.com/

I have the following code

           // Create a request for the URL.             
           WebRequest request = WebRequest.Create("http://mywebsite.info/External/NewUser.aspx");
           // If required by the server, set the credentials.
           request.Credentials = CredentialCache.DefaultCredentials;
           // Get the response.
           HttpWebResponse response = (HttpWebResponse)request.GetResponse();
           // Display the status.
           Console.WriteLine(response.StatusDescription);
           // Get the stream containing content returned by the server.
           Stream dataStream = response.GetResponseStream();
           // Open the stream using a StreamReader for easy access.
           StreamReader reader = new StreamReader(dataStream);
           // Read the content.
           string responseFromServer = reader.ReadToEnd();
           // Display the content.
           lblResult.Text = responseFromServer;
           // Cleanup the streams and the response.
           reader.Close();
           dataStream.Close();
           response.Close();

The strange thing is i can run it fine on a local iis server but it gives this error on the public server

I have contacted the webhost and explained the problem but they are unable to help and are only requesting that i tell them what i need them to do to get it working. but i' at a loss.

Does anyboday have any ideas why this may work locally but not on a public webhost

Some sort of IIS settings maybe permissions.

Thanks
John
0
johngrant_ks
Asked:
johngrant_ks
  • 6
  • 4
  • 4
1 Solution
 
MlandaTCommented:
Have a look at the various techniques discussed in this article on how you may begin to approach this problem: http://forums.iis.net/t/1152487.aspx
0
 
MlandaTCommented:
also... are you able to access http://mywebsite.info/External/NewUser.aspx from anywhere else (other than your local network?)
0
 
MlandaTCommented:
what happens if you use the IP address instead of the domain name?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MlandaTCommented:
if you need to initiate a connection from your host to the outside world... do you need proxy or other authentication settings? http://dasgarner.blogspot.com/2008/03/webrequest-proxy-authentication.html
0
 
johngrant_ksAuthor Commented:
Thanks for a respones

I can access the page normally if i dont use webrequest

It is actual a connection back to the host with in the same domain so it doesnt need to access the out side world.

I will check with the host if i need to  have auth or proxy
0
 
johngrant_ksAuthor Commented:
I dont have a fixed IP Address to test if using the ip will work, but i'm going to havbe one soon
0
 
Bob LearnedCommented:
I usually try to approach this type of problem by getting information.  There is a lot going on under the hood, when working with a browser, and a server, that you never see.  

If you haven't used an HTTP debugger, than I would suggest getting to know one, like Fiddler (a free HTTP debugger).

Web Debugging Proxy
http://www.fiddler2.com/fiddler2/

There are a few places where HTTP web requests can go wrong, so without that kind of information, it is darn near impossible for others to help.
0
 
johngrant_ksAuthor Commented:
Thanks TheLearnedOne appreciate the tip to use fiddler, I have never used an http debuger and finding a bit hard to understand in what part of the program i could use to see where the problem could lie.

I forced the error to occur while fiddler was running but could not see anything that may help.

1. because i think the problem lies on the server, forgive my iggnorance but does fiddler detect what is happening on the server?

If you could point me in the right direction where to look in fiddler would be much appreciated.

Thanks
John
0
 
Bob LearnedCommented:
John,

I totally understand the difficulty with using a new tool, like Fiddler, since it presents you with so much information, that.  Also, it is not a perfect debugging solution, since some requests may not get captured.  

I believe that a good starting point would be to see the list of request traffic when you are using the browser, which I thought you said was working.  We need to discover what works, and that is where an HTTP "sniffer", like Fiddler, comes in.  

Start Fiddler, make some a request through the browser, and take a screen shot of the main list, so that we can decide which request to look at.  Attach the image to this question.

Bob
0
 
johngrant_ksAuthor Commented:
Hi TheLearnedOne

Well after getting fiddler to work for a localhost by downloading IE9 which worked nicely, but one problem i have found with IE9 you cant upload files, dont know what has gone on there.

I went to recreate the problem on the localhost and started to get the same server 500 error fixed ran it on the webhost and all is working fine :)

Other than a mistake on my part, this has not been a lost cause i will find using fiddler from now on very helpful and would like to thank you again for pointing me to this tool, it will fill in a few blank areas i have in my understanding of web technologies.

If you would like to claim the 250 points i can assign them to you? but it does not look like you need them and it would not be good to have this question as being answered because it was my mistake and there is no clear problem or solution. But the pointer to fiddler may be helpful to some.

thanks again
John
0
 
Bob LearnedCommented:
John,

I am not sure that I understand the "mistake on your part"...are you saying that your problem is solved?

Bob
0
 
johngrant_ksAuthor Commented:
Hi Bob

Yes i was able to fix the issue, My problem was i had 3 different version of the project running on 3 different computers and the versioning was a bit outdated between them all causing me to assume i had a working version locally and one that was not working on the web host, but when i was tring to get the working version working locally i dicovered that the local version also had the same error debuged it fix the error uploaded the changes to the web host and all works now.

It was a null reference to a request object causeing the webrequest request to return the server 500 error.

Did you want the 250 points?
0
 
Bob LearnedCommented:
I always say, if you found something useful, but not completely a solution, you can request to assign a fraction of the points to me, and have the rest refunded.
0
 
johngrant_ksAuthor Commented:
The problem was something i had overlooked, althought the soulution was something i should have found i did learn alot from this exercise and appreciate bobs help
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now