if(Session["login"]==null)
{
   Response.Write("-1");    }
// 在此处放置用户代码以初始化页面
try
{
Response.ContentType = "text/plain";   
Response.Charset = "utf-8"; HttpPostedFile file = Request.Files["Filedata"];   
string  uploadPath = HttpContext.Current.Server.MapPath(@Request["folder"]) +"\\"; 
// if(file.ContentLength)
if (file != null)  
{
//if(file.ContentLength>10857600)
   {
   if (!Directory.Exists(uploadPath))  
   {  
   Directory.CreateDirectory(uploadPath);  
   }  
   string PathName=uploadPath+System.DateTime.Now.ToString("yyyMMddhhmmss") + Session.SessionID.ToString()+file.FileName;
   file.SaveAs(PathName);
   Session["path"]=PathName;
   //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
   Response.Write("1"); 
   }
}   
else  
{   
Response.Write("0");   
}我在客户端怎么获取Response.Write("-1")的值啊!请各位帮帮忙啊!

解决方案 »

  1.   

    获取-1,这段代码是放在PageLoad时间里面的。
      

  2.   

    不明白你想要啥,不过你的代码缺了个catch。    protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["login"] == null)
            {
                Response.Write("-1");
                Response.End();//可能是你想要的结果。        }
            // 在此处放置用户代码以初始化页面 
            try
            {
                Response.ContentType = "text/plain";
                Response.Charset = "utf-8";            HttpPostedFile file = Request.Files["Filedata"];
                string uploadPath = HttpContext.Current.Server.MapPath(@Request["folder"]) + "\\";
                // if(file.ContentLength) 
                if (file != null)
                {
                    if (!Directory.Exists(uploadPath))
                    {
                        Directory.CreateDirectory(uploadPath);
                    }
                    string PathName = uploadPath + System.DateTime.Now.ToString("yyyMMddhhmmss") + Session.SessionID.ToString() + file.FileName;
                    file.SaveAs(PathName);
                    Session["path"] = PathName;
                    //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 
                    Response.Write("1");
                }
                else
                {
                    Response.Write("0");
                }
            }
            catch
            { }
        }
      

  3.   

    呵呵  就是 ,我刚才 还没看出来,还真的 少了一个  catch  关键字啊!