1、将debug对象设定为true,然后进行调试,调试完毕可改为false,那么浏览器中就不会显示出错的位置。不过错误信息的提示与否还要和站点配置文件Global.asax配合使用,需要在该文件中添加错误处理函数,如:
void Application_Error(Object sender,EventArgs E)
{
//将错误信息显示出来
Response.Write(E.ToString);
//清楚错误
//Context.ClearError();
//跳转到指定页面
//Response.Redirect("/errorpage.aspx");
}
单个文件调试<% @page ...................debug="true"...>
还可以使用compilation标签 Web.Config文件中compilation标签来设定。
<compilation defaultLanguage="C#" Debug="true">
TRACE
使用Trace有两种方式
1、在网页的Page属性上加入Trace对象,如:
< % @ Page ..........trace="true"....... >
2、在相应的Web.Config文件中加入Trace对象,如:
<trace enabled="true" requestLimit="10" pageOutput="true" traceMode="SortByTime" localOnly="true"/>