小编Joh*_*ohn的帖子

System.Web.HttpException:此上下文错误中没有响应

描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.

异常详细信息:System.Web.HttpException:响应在此上下文中不可用.

Source Error: 


Line 10:    public void Download(string filename)
Line 11:    {
Line 12:         Response.ContentType = "application/exe";
Line 13:         Response.AppendHeader("Content-Disposition", filename);
Line 14:         Response.TransmitFile(Server.MapPath("~/Resources/bb.exe"));
Run Code Online (Sandbox Code Playgroud)

我在一个类中有这个方法,当我点击一个按钮时我调用这个方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class Common: System.Web.UI.Page
{
}
Run Code Online (Sandbox Code Playgroud)

我哪里错了

c#

7
推荐指数
1
解决办法
2万
查看次数

资源解释为其他但传输的MIME类型未定义.IE的错误(Asp.net网站)

在此输入图像描述

当我尝试从Chrome下载它工作正常,但在IE 8中它没有下载它显示上面的错误,

    protected void btn_ExcelDownload_Click(object sender, EventArgs e)
{
    Grid_UserTable.Columns[0].Visible = false;
    string subject = lbl_Subj.Text;
    Response.Buffer = true;
    Response.Clear();
    Response.ClearHeaders();
    Response.AddHeader("Cache-Control", "no-store, no-cache");
    Response.AddHeader("content-disposition", "attachment;filename=" + subject + "-Status.xls");
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.ms-excel";
    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    Grid_UserTable.RenderControl(htmlWrite);
    rptList.RenderControl(htmlWrite);
    Response.Write(stringWrite.ToString());     
    Response.End();
}
Run Code Online (Sandbox Code Playgroud)

当我在chrome中使用开发人员工具时,它将Resource解释为Other,但是使用MIME类型undefined进行传输.错误,但下载了文件,但IE正在抛出图像中显示的错误,我该怎么办,谢谢.

当我使用Visual Studio运行网站时,我能够在IE8中下载该文件,但是当我尝试从上传到服务器的网站下载时,我收到上述错误,错误仅在IE 8中.

我尝试打开和关闭IE浏览器兼容模式,即使这样我也收到同样的错误.

这是我的头脑内容

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
Run Code Online (Sandbox Code Playgroud)

c# asp.net cross-browser download

6
推荐指数
1
解决办法
2861
查看次数

文本框验证器的最小长度

     <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" 
ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">
 </asp:RequiredFieldValidator>
Run Code Online (Sandbox Code Playgroud)

如何验证文本框以输入长度大于8且必须包含1个数字和1个大写字母的值。

asp.net validation

5
推荐指数
2
解决办法
2万
查看次数

如何查找是否在asp.net中选中了复选框列表

如何在asp.net的复选框列表中获取所选索引.我应该循环查找是否已选中列表框,或者我可以在不这样做的情况下了解.我想做这个

if(选中Checkboxlist){do this} else {do this}

如何查找是否在asp.net中选中了复选框列表

int roleselected = ckl_EditRole.Items.SelectedIndex;
Run Code Online (Sandbox Code Playgroud)

asp.net checkboxlist

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×3

c# ×2

checkboxlist ×1

cross-browser ×1

download ×1

validation ×1