XML 解析错误:未找到元素 位置:http://localhost:2625/Handler3.ashx 行 1,列 1:
一个script文件 一个ashx 用来上传文件。文件能上传,但是传完会报这个错误
怎么解决?
//script
$(document).ready(function () {
$("#btnUpLoad").click(function () {
$("#form1").ajaxSubmit({
url: "Handler3.ashx",
type: "post",
resetForm: "true",
beforSubmit: function () {
},
success: function (msg) {
return true;
},
error: function (jqxhr, errorMsg, errorThrown) {
return false;
}
})
});
})
//ashx
HttpPostedFile upFile = HttpContext.Current.Request.Files["upLoad"];
if (upFile.ContentLength> 0)
{
try
{
upFile.SaveAs(context.Server.MapPath("~/") + upFile.FileName);
}
catch (Exception)
{
throw;
}
不用管那个错误,那个是因为页面没有返回任何信息就会提示那个错误
你有强迫症的话,就context.Response.Write("OK");随便输出一些内容就行
page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script type="text/javascript" defer>" + script + "</script>");
当使用Registe......
答案就在这里:错误"XML解析错误:未找到元素"的解决方案。
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?
firefox,默认解析的是 header(text/html),最佳办法是输出添加 header ( text/plain)