首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

asp.net有没有类似ASP里的Response.End 语句?该怎么解决

2012-04-06 
asp.net有没有类似ASP里的Response.End 语句?asp.net某页面代码为:%@PageLanguage c# %scriptrunat

asp.net有没有类似ASP里的Response.End 语句?
asp.net某页面代码为:


<%@   Page   Language= "c# "   %>
<script   runat= "server ">

        void   StructuredErrorHandling   ()
        {
            try
            {
                int   []   array   =   new   int[9];
                for(int   intCounter=0;   intCounter   <=   9;   intCounter++)
                {
                    array[intCounter]   =   intCounter;
                    Response.Write( "The   value   of   the   counter   is: "   +   intCounter   +
                                                                                                                            " <br> ");
                }
            }
            //   Handler   for   index   out   of   range   exception
            catch   (IndexOutOfRangeException   ex)
            {
                  Response.Write( "Error   Occurred "+   " <br> "   +   ex.ToString()   +   " <br> ");
            }
            //   Handler   for   generic   exception
            catch   (Exception   e)
            {
                  Response.Write( "Generic   Error   Occurred "   +   " <br> ");
            }
            finally
            {
                  Response.Write( "The   Page   Execution   is   completed "   +   " <br> ");
            }
        }

</script>
<%
    StructuredErrorHandling();
    Response.Write( "Function   call   completed "   +   " <br> ");
%>
<html>
<head>
        <title> Structured   Error   Handling   Example </title>
</head>
<body>
        <form   runat= "server ">
        </form>
</body>
</html>


执行结果:

The   value   of   the   counter   is:0 <br> The   value   of   the   counter   is:1 <br> The   value   of   the   counter  



is:2 <br> The   value   of   the   counter   is:3 <br> The   value   of   the   counter   is:4 <br> The   value   of   the   counter  

is:5 <br> The   value   of   the   counter   is:6 <br> The   value   of   the   counter   is:7 <br> The   value   of   the   counter  

is:8 <br> Error   Occurred <br> System.IndexOutOfRangeException:   索引超出了数组界限。
      at   ASP.structuredErrorHandling_aspx.StructuredErrorHandling()   in  

D:\INetPub\WWWROOT\net\study\aspdotnet1.1\Ch14\structuredErrorHandling.aspx:line   11 <br> The   Page  

Execution   is   completed <br> Function   call   completed <br>
<html>
<head>
        <title> Structured   Error   Handling   Example </title>
</head>
<body>
        <form   name= "_ctl0 "   method= "post "   action= "structuredErrorHandling.aspx "   id= "_ctl0 ">
<input   type= "hidden "   name= "__VIEWSTATE "   value= "dDwtMTI3OTMzNDM4NDs7Pic3uXpLBHmL+YMd/VTK5Ew+KEfr "   />

        </form>
</body>
</html>


我不想要下面的HTML代码:
<html>
<head>
        <title> Structured   Error   Handling   Example </title>
</head>
<body>
        <form   name= "_ctl0 "   method= "post "   action= "structuredErrorHandling.aspx "   id= "_ctl0 ">
<input   type= "hidden "   name= "__VIEWSTATE "   value= "dDwtMTI3OTMzNDM4NDs7Pic3uXpLBHmL+YMd/VTK5Ew+KEfr "   />

        </form>
</body>
</html>


ASP里可以通过Response.End   实现,ASP.NET应该如何做?


[解决办法]
ASP.NET也有 Response.End

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

最新版本:20070212

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html

热点排行