以前学C#的时候,都是用"return"
现在弄Web,觉得没必要用Response.End()
它们有什么区别?请指教。

解决方案 »

  1.   

    Response.End()
    是停止页面html代码的书写
    return
    是返回停止该函数操作
      

  2.   

    Response.End() 
    是停止服务器端页面代码输出
      

  3.   

    这两个好像没有什么关系的吧。response.end应该表示应答结束的吧。
      

  4.   

    例如:
    protected void Page_Load(object sender, EventArgs e)
        {
            Response.End();
           
        }
    输出:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head><title>
    无标题页
    </title></head>
    <body>
        <form name="form1" method="post" action="Default.aspx" id="form1">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGSr3Z4GoFkkYIkS3gjEDZgu5z75Fg==" />
    </div>    <div>
           
        </div>
        </form>
    </body>
    </html>
    protected void Page_Load(object sender, EventArgs e)
        {
            return;       
        }
    输出:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=gb2312"></HEAD>
    <BODY></BODY></HTML>
      

  5.   

    你的意思是:就算用了Response.End(),下面的代码继续执行(除了页面html代码的书写)?
      

  6.   

    return是用在方法中的
     表示跳出方法 
    response.end则是停止运行代码,直接输出
      

  7.   


    Response.End()
    是停止对Html中
    <body>内容的输出
    Return是建立好了各个组件,停止数据处理
      

  8.   

    return是用在方法中的 
     表示跳出方法  
    response.end则是停止运行代码,直接输出
    停止的应该是js代码吧