私はASP.NET Webサービスを持っており、要求のフィールドのいくつかは列挙型として定義されています。空白または無効な値を入力する場合、応答が返ってくるよう:要求の解析中に例外をキャプチャする
Parameter name: type ---> System.ArgumentException: Must specify valid information for parsing in the string.
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
それは、このようなエラーをキャプチャし、代わりにXMLベースの応答を返すことは可能ですか?
いいえ、この例外はWebサービスハンドラによってスローされ、ユーザの土地コードではありません。だからあなたはそれの周りにラッパーを置くことはできません。 –
global.asaxでさえない? –
いいえ、global.asaxのエラーハンドラにアタッチしても起動しません。 –