(414) 在 asp.net 中创建 pdf 时请求 URI 太大

发布于 2024-08-13 04:31:56 字数 2318 浏览 3 评论 0原文

我使用以下代码(asp.net)为用户显示 pdf:

Response.ContentType = "Application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=thePdf.pdf");

//data contains a pdf created with iTextSharp
Response.OutputStream.Write(data, 0, datalength);
Response.End();

有时用户会收到错误。我无法重现该问题,但这是我在日志中看到的内容,似乎总是 Mozilla 4 或 5 存在该问题:

Error Message: The remote server returned an error: (414) Request-URI Too Large.
Error Source: System
Error Target Site: System.Net.WebResponse GetResponse()


Exception Stack Trace:
----------------------
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.my_doexport_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Server Variables:
-----------------
ALL_HTTP: HTTP_CACHE_CONTROL:no-cache
HTTP_CONNECTION:Keep-Alive
HTTP_ACCEPT:image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_ACCEPT_LANGUAGE:de
HTTP_COOKIE:ASP.NET_SessionId=xxxxxxxxxxxxa0jo0pxxxxxx; .ASPXFORMSDDDO=XXX436F9868122C336C1E358DBFB1E908F3767FABAEF5338CF62C785ADD6AEA23F8663B413A7C0634DC40F8DCD3B10889CB0FB4CEE18617FB8B1E87C9655AE69C274A1AD0A5F47D95BF8D502F459D05D09A2B0E3691C6737B679F72C6B0XXXXX; __utma=213584726.23687335.1259423588.1259423588.1259423588.1; __utmb=213584726.10.10.1259423588; __utmc=213584726; __utmz=213584726.1259423588.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
HTTP_HOST:www.domain.com
HTTP_REFERER:http://www.domain.com/export.aspx
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.3; .NET CLR 1.1.4322)

我还没有找到该问题的解决方案,您有什么解决方案吗?如何解决它的想法?

I'm using the following code (asp.net) to show a pdf for the user:

Response.ContentType = "Application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=thePdf.pdf");

//data contains a pdf created with iTextSharp
Response.OutputStream.Write(data, 0, datalength);
Response.End();

Sometimes the users gets an error. I have not been able to recreate the problem but this is what I've seen in my logs and it seems like its always Mozilla 4 or 5 that have the problem:

Error Message: The remote server returned an error: (414) Request-URI Too Large.
Error Source: System
Error Target Site: System.Net.WebResponse GetResponse()


Exception Stack Trace:
----------------------
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.my_doexport_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Server Variables:
-----------------
ALL_HTTP: HTTP_CACHE_CONTROL:no-cache
HTTP_CONNECTION:Keep-Alive
HTTP_ACCEPT:image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_ACCEPT_LANGUAGE:de
HTTP_COOKIE:ASP.NET_SessionId=xxxxxxxxxxxxa0jo0pxxxxxx; .ASPXFORMSDDDO=XXX436F9868122C336C1E358DBFB1E908F3767FABAEF5338CF62C785ADD6AEA23F8663B413A7C0634DC40F8DCD3B10889CB0FB4CEE18617FB8B1E87C9655AE69C274A1AD0A5F47D95BF8D502F459D05D09A2B0E3691C6737B679F72C6B0XXXXX; __utma=213584726.23687335.1259423588.1259423588.1259423588.1; __utmb=213584726.10.10.1259423588; __utmc=213584726; __utmz=213584726.1259423588.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
HTTP_HOST:www.domain.com
HTTP_REFERER:http://www.domain.com/export.aspx
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.3; .NET CLR 1.1.4322)

I haven't found a solution to the problem, do you have any ideas on how to solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゝ杯具 2024-08-20 04:31:56

错误消息明确显示了Request-URI。这个问题似乎与您的回答没有任何关系;用于生成错误的 url 是什么?

the error message is explicit about Request-URI. the problem doesn't seem to have anything with your response; what is the url used to generate the error?

小苏打饼 2024-08-20 04:31:56

HTTP 错误按以下方式进行分类

1xx - Informational
2xx - Successful 
3xx - Redirection
4xx - Client error
5xx - Server error

您的 414 错误一定是一个错误由客户端生成,与您的服务器代码无关。您的浏览器发送的 URL 太大,网络服务器无法正确处理。

那么,网址的最大长度是多少?

链接也很有帮助: HTTP 414 请求 URI 太大和 Firefox

HTTP errors are categorized following way:

1xx - Informational
2xx - Successful 
3xx - Redirection
4xx - Client error
5xx - Server error

Your 414 error must be an error generated by client, not related to your server code. Your browser sent a URL too large to be properly handled by your web server.

So, what is the maximum length of an url?

This link can also be helpful: HTTP 414 Request-URI Too Large and Firefox

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文