Yes, my site is an asp.net web application. The error occurs anytime I try to load something using XDocument.load() that isn't in proper XML format. Wrapping it in a try block like I show above does no good. You can't validate the XML against an XML schema util you have it loaded...kind of a catch 22 in my case. I don't like the idea that XDocument(url) can stop my web-application from functioning (internal 500 error). The error does not come from my web-app code, it comes from the server running my web-application anytime I try to load fouled-up XML. My hack has it working for now but I am certain that I am overlooking something simple. I guess if there were a simple fix, someone would have posted it by now. Thanks again,
Enochs
Posts
-
XML from URL Causes Internal Server Error (500) -
XML from URL Causes Internal Server Error (500)That is what my "Ugly Hack" that I posted does. Using 7 lines of code, it reads the XML into a string and looks at that string before deciding if the XML is to be loaded. Just seems like a terrible waste of time/resources. I don't understand why it doesn't simple kick out an XmlException as the documentation says it should. The server 500 error gets me every time. Thanks for responding.
-
XML from URL Causes Internal Server Error (500)I use a web based look-up service to obtain detailed information on IP addresses. It works great until the service goes down and the URL fails to render proper XML. The error (when the service is down) occurs on the "xDoc = XDocument.Load(url)" statement but does NOT throw an XmlException that I can catch...instead the server (I use a host) locks up with an internal (500) error. Since this error is from the server and not my application, I get no stack trace. All of my XML validation methods are predicated on the fact that I have the XDocument loaded first....then validate against an XML schema. But it's the load that fails so I have no chance to validate the XML. Any Ideas?
string url = String.Format("http://www.ipgp.net/api/xml/{0}/{1}", sourceIP, password);
try
{ /* This returns an internal server
* error (500) if the url fails to
* render proper xml. No error
* gets thrown. */
xDoc = XDocument.Load(url);
}
catch (XmlException ex)
{
/* This is a safe xml document
* that I would like to load if
* the load fails. */
xDoc = XDocument.Load(safe);
}UPDATE: I figured out this UGLY hack to get around the problem for now. The following code first reads the webpage into a variable and then checks the variable for an XML tag that I know should be present. If XML tag can't be found then my default (safe) xml loads. I hope someone can PLEASE give me a better fix...thanks
HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sr.Close();
myResponse.Close();if (ExactMatch(result, ""))
xDoc = XDocument.Load(url);
else
xDoc = XDocument.Load(Safe); -
Simple SQL format questionThanks, that worked. Kind of funny how simple that was. In the time it took to get a response, I wrote a complicated Regular Expression Validator control to get around the issue..... Let me go delete that. lol
-
Simple SQL format questionI am having problems with the following SQL command: SELECT * FROM Classes ---Works like a charm SELECT * FROM Classes WHERE Class_Number = 2222 ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting the nvarchar value '11-1111' to data type int. ---I can understand that. Without quotes, sql thinks the Class_Number column is of type int (its actually nvarchar). So let me add quotes... _______________________________ SELECT * FROM Classes WHERE Class_Number = "2222" ---Fails with this error: System.Data.SqlClient.SqlException (0x80131904): Invalid column name '2222'. Now that error has me stumped!!! What am I missing here?:mad:
-
How can I create an oddly shaped GUI ?I have completed an application that looks boring. I can add graphics to my WPF based GUI but what I would like to do is change the entire shape of the GUI itself. The best example I can think of is that of changing skins on a media player... by changing the skins you can change the overall shape of the GUI as well as the placement of the controls. One skin may be an 800 pound guerrilla while another might be a hamburger. I would be able to change it with the click of a button. I can easily place a picture of a guerrilla into my WPF based GUI and place the controls on it but the GUI itself that contains the guerrilla picture still has four straight sides.... I want my GUI to morph into the shape of the primate. Can someone point me in the right direction? And to complicate things.... Another idea we have is to place controls on each of the six sides of a cube. Once we have the GUI assume the shape of the cube we would like the user to be able to use their mouse and spin the cube around by clicking and dragging....thus accessing the controls on the other sides. And could we do all that using finger input on a touch sensitive screen? ... Can someone point me in the right direction on that idea? Thanks, Jay