响应对象导致403禁止?
在我的服务器端代码中,我创建了以下响应对象:
var response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", content.Type);
response.AddHeader("Content-Length", content.Length.ToString());
response.AddHeader("Content-Disposition",
string.Format("attachment; filename={0}; size={1}", Server.UrlEncode(content.FileName), content.Length.ToString()));
response.Flush();
response.BinaryWrite(content.Image);
response.Flush();
此响应对象中的某些内容是否可能导致 403,如果是的话,又是什么?如果我只是运行一个空白的 aspx 页面,我不会得到 403,只有当它执行上面的代码时才会出现 403。
In my server side code I'm creating the following response object:
var response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", content.Type);
response.AddHeader("Content-Length", content.Length.ToString());
response.AddHeader("Content-Disposition",
string.Format("attachment; filename={0}; size={1}", Server.UrlEncode(content.FileName), content.Length.ToString()));
response.Flush();
response.BinaryWrite(content.Image);
response.Flush();
Is it possible something in this response object is causing the 403 and if so what? If I just run a blank aspx page I don't get a 403 it is only when it goes through the above code that a 403 occurs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题不太可能是 MIME 类型问题(因此可能与
text/plain
内容类型无关),尽管这本身就是一个问题。可能是权限设置不正确,或者 .NET 未在服务器上正确注册。尝试再次在服务器上运行
aspnet_regiis
。The issue is unlikely to be a mime type issue (so probably not related to the content type being
text/plain
), though that's an issue in itself.Chances are that permissions are not setup correctly, or that .NET is not registered on the server properly. Try running
aspnet_regiis
on the server again.