复制代码 代码如下:
if (SecurityManager.IsGranted(new AspNetHostingPermission(AspNetHostingPermissionLevel.Medium)))
{
}
参考链接:
MSDN 《trust 元素(ASP.NET 设置架构)》
MSDN 《How To: Use Medium Trust in ASP.NET 2.0》
《Check Code Access Security Permissions Granted to your asp.net web application》
附录B
辰 提供的文件下载方案:
复制代码 代码如下:
protected override void OnInit(EventArgs e)
{
Response.ContentType = "application/octet-stream";
using (FileStream stream = File.Open(Server.MapPath("~/test.txt"), FileMode.Open))
{
BinaryWriter writer = new BinaryWriter(Response.OutputStream);
byte[] buffer = new byte[1024];
int l = 0;
while ((l = stream.Read(buffer, 0, buffer.Length)) > 0)
{
writer.Write(buffer, 0, l);
}
}
}
新闻热点
疑难解答
图片精选