如何获取错误消息 [英] How to get the error message

查看:74
本文介绍了如何获取错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想收到错误消息



I want to get error message

string server = "";

       if (server != Dns.Resolve(domain).ToString())
       {
           string na = "Not Available!";
           Response.Redirect("domainsearch.aspx?Name=" + na);
       }
       else
       {

           string nas = "Available!";
           Response.Redirect("domainsearch.aspx?NoName=" + nas);
       }







如何检查此情况并收到错误消息另一页

推荐答案

请参阅使用try catch并通过查询字符串发送异常消息



See Use try catch and send exception message by the querystring

string server = "";
      try
      {
          if (server != Dns.Resolve(domain).ToString())
          {
              string na = "Not Available!";
              Response.Redirect("domainsearch.aspx?Name=" + na);
          }
          else
          {
              string nas = "Available!";
              Response.Redirect("domainsearch.aspx?NoName=" + nas);
          }
      }
      catch (Exception ex)
      {
              Response.Redirect("domainsearch.aspx?NoName=" + ex.Message);
      } 


试试这个:



Try this:

string name=request.querystring("Name");
string noName=request.querystring("NoName");





查看以获取更多信息: Querystring



我希望这会对你有所帮助。



Check this for more info : Querystring

I hope this will help to you.


使用try catch block

由sankarsan parida定义

或将你的错误放在你想要的地方





ex:

Use try catch block
as defined by sankarsan parida
or put your error where you wanted


ex:
lbl.text="error"+ex.Message;


这篇关于如何获取错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆