asp.net mvc - Unable to reference the InnerException.Message inside Catch(Exception ex) -
i have following code part of action method inside asp.net mvc web application:-
catch (exception ex) { using (var client = new webclient()) { var query = httputility.parsequerystring(string.empty); xmldocument do2c = new xmldocument(); query["username"] = system.web.configuration.webconfigurationmanager.appsettings["apiusername"]; query["password"] = system.web.configuration.webconfigurationmanager.appsettings["apipassword"]; query["assettype"] = routedata.values["controller"].tostring(); query["operation"] = "deleteasset"; query["assetname"] = vmj.resource.resourcename; query["accountname"] = vmj.customer.name; query["sitename"] = sitename; string apiurl = system.web.configuration.webconfigurationmanager.appsettings["apiurl"]; var url = new uribuilder(apiurl); url.query = query.tostring(); try { string xml = client.downloadstring(url.tostring()); xmldocument doc2 = new xmldocument(); doc.loadxml(xml); } catch (webexception ex2) { modelstate.addmodelerror(string.empty, "error occurred:" + ex2.innerexception.message); } //} //} } modelstate.addmodelerror(string.empty, "error occurred:" + ex.innerexception.message); } }
but when exception ex
occur, unable display innerexception.message, , null reference exception when trying reference innerexception.message. although have added brake point , ex object contains both inner-exception , message describing exception. idea going on ?
Comments
Post a Comment