正确的写法是
Request.Form["content"]Request["content"] 是获取querystring
Request.Form["content"]Request["content"] 是获取querystring
解决方案 »
- 请教关于sso的几个问题!
- 一个浏览器不兼容的问题
- 请教一个jquery 实现input type="button"的背景图片变换
- vs2010 中网站调试没有问题,但是发布后在浏览时却显示:“/”应用程序中的服务器错误 未将对象引用设置到对象的实例。具体错误如下:
- 怎么给updatepanel中的空间注册onblur事件?
- “System.Web.UI.Control”并不包含对“DataItem”的定义
- this.textBox1.Text与 textBox1.Text的区别,小弟先谢哈
- SQL语句写错了??????在线等
- C# post请求 使用Etag/if-none-match 实例
- 有关于DataGrid 分页的简单问题,在线等待~~~~~
- 高分求助 !!数组组合问题
- asp.net三层架构中缓存层如何搭建,求大神指教~!
Request.Form["content"]Request["content"] 是获取querystring
Request.Form["content"] 到控制器里还是没有数据啊
Request.Form["content"]Request["content"] 是获取querystring
Request.Form["content"] 到控制器里还是没有数据啊
如果你要传递 Html 内容,要在action 上面 取消 对post 内容的校验:加上
[ValidateInput(false)]
[HttpPost]
public FileResult ExportExcel( FormCollection form )
{
}
<table >
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
</div>
<button id="btnExport">Export</button>
<iframe id="export" name="export" style="display:none"></iframe>
<form name="excel" method="post" action="/Home/ExportExcel" target="export">
<input type="hidden" name="content" id="content" />
</form>
<script type="text/javascript">
$(
function () {
$("#btnExport").click(function () {
console.log($("#exporttable").html());
$("#content").val($("#exporttable").html())
document.forms["excel"].submit();
} //click end
);
}
);
</script>
controller.cs:
[HttpPost]
[ValidateInput(false)]
public FileResult ExportExcel(string content)
{
//第一种:使用FileContentResult
//string content = Request["content"];
byte[] fileContents = Encoding.Default.GetBytes(content);
return File(fileContents, "application/ms-excel", "课程设计选题情况.xls");
}web.config:
<system.web>
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
Request.Form["content"]Request["content"] 是获取querystring
Request.Form["content"] 到控制器里还是没有数据啊
如果你要传递 Html 内容,要在action 上面 取消 对post 内容的校验:加上
[ValidateInput(false)]
[HttpPost]
public FileResult ExportExcel( FormCollection form )
{
}会报错,应该就死 saucer 大神说的那个吧,检测到有潜在危险的 Request.Form 值
string content=Request["content"];
byte[] fileContents = Encoding.Default.GetBytes(content);
return File(fileContents, "application/ms-excel", "课程设计选题情况.xls");
使用这种 导出的excel中的汉字变成乱码了 有什么解决的好方法