问题标签 [response.write]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
110778 浏览

asp.net - ASP.Net 下载文件到客户端浏览器

我正在编写一个简单的测试页面,以便在单击按钮时从浏览器下载文本文件。我遇到了一个我从未见过的非常奇怪的错误。有什么想法吗?

发生错误Response.End();,文件永远不会到达客户端浏览器

代码:

错误:

无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部。

0 投票
0 回答
752 浏览

httpwebrequest - GetResponse() 的返回 URL 会话丢失

我正在从 Page1 到 Page2 发出 WebRequest。Page2 处理信息并发送 URL 链接 (http://xyz/abc/Page3.aspx) 以响应 Page1。

Page2 和 Page3 属于同一个解决方案并共享会话变量。

在 Page1 中,一旦收到响应。它选择 page2 发送的 URL 并尝试访问它。但不幸的是,第 3 页中的会话丢失了。我期待存储在 Page2 中的会话变量可以在 Page3 中访问。

在 Page1 中: WebRequest 请求 = WebRequest.Create("page2");
...
request.GetResponse();
...
字符串 urlStr=getURL();
//这个url有链接到
Page3 Response.Redirect(urlStr);

在第 2 页: Session["guid"]="stackoverflow";
...
Context.Response.Write(xmlString);
Context.Response.End();

在第 3 页中: //这里是我丢失了会话值
String temp= Convert.ToString(Session["guid"]);

更新:
第 1 页中的解决方案: request.CookieContainer = new CookieContainer();
..
System.Net.WebResponse 响应 = request.GetResponse();
CookieCollection respCookieCollection= ((HttpWebResponse)response).Cookies;

...
//使用从先前响应中获得的 cookie 创建新请求以导航到 Page3。HttpWebRequest request2 = (HttpWebRequest)HttpWebRequest.Create(url); request2.Method = WebRequestMethods.Http.Post;request2.CookieContainer = new CookieContainer(); request2.CookieContainer.Add(respCookieCollection);
.... System.Net.WebResponse response2 = request2.GetResponse(); System.IO.StreamReader reader2 = new System.IO.StreamReader(response2.GetResponseStream()); 字符串 str2 = reader2.ReadToEnd(); Response.Write(str2);

0 投票
0 回答
8155 浏览

c# - 写入 httpResponse 时,响应是否有大小限制?

我在 ASP .Net C# 中动态生成一个 CSV 文件,并将其直接写入响应。

在大多数情况下这很好用,但在某些情况下我会收到错误消息(“此网站无法在 Internet Explorer 中显示”)。我怀疑原因是这个文件对于响应来说变得太大了。在那种情况下,如何延长响应长度的限制?

我希望我可以在 web.config 文件中执行此操作,类似于将 mexRequestLength-property 设置为 httpRuntime-element (http://msdn.microsoft.com/en-us/library/e1f13641.aspx) .

谢谢!

0 投票
1 回答
285 浏览

javascript - Response.Write - how do I get rid of the script now?

I used Response.Write to write dynamic javascript into a page to test some values in code using an alert box (couldn't step through on a test machine using a build). I've reverted the code, Rebuilt, deleted all the temp data from IE and the alert still shows.

I implemented this through a recommendation (foolishly, apparently) and now I can't get rid it.

Can anyone tell me how to "undo" this?

0 投票
4 回答
24788 浏览

asp.net - Response.Write and UpdatePanel

I generate a vcard that I send to the client using the following code snippet:

However, I need to use vCards on a page that has the control inside and UpdatePanel. Unfortunately, according to Update panel and Response write this does not work and causes an error. I am wondering what are some alternative ways to send the contents of the vcard/file to the client's browser and have it display "open/save" dialog that don't involve Response.Write?

0 投票
1 回答
585 浏览

sql - SQL Azure 数据不写入?

我是 Azure 的新手,正在为我公司的内部公司网站探索它。我们一直在使用本地 MS SQL 2008 Express 数据库,我已将其设置为与 Azure 同步以进行测试。一切都完美同步,所有数据都在那里,但由于某种原因,我的 ASP 代码中不会遇到一个数据点。

数据点是一个 pdf 文件名。我没有将文件存储在数据库中,只是文件名(现在)。在本地 SQL 服务器上一切正常,但由于切换没有运气。奇怪的是 if 语句仍然适用于数据,它只是不会将文件名放在我的 response.write() 方法中,因此,它不会将文件名放在我的链接中供用户下载。

有人有想法吗?

0 投票
2 回答
535 浏览

c# - ASP.NET 页面流信息

所以我正在尝试使用 C# 来获取数据库中存储的 HTML,然后在一组 HTML 页眉和页脚之间显示它(我有几个用于不同的页面,所以母版页会让生活变得更加复杂而不是更少。我也来自 PHP 背景,这是一种工作方式)。

不幸的是,在当前的工作流程中,代码会在页眉或页脚放在页面上之前生成内容,将所有存储的 HTML 放在页眉之前的页面顶部。我已经尝试了几个不同的 Page_Events,但它们似乎都不起作用,所以我需要知道该怎么做。

是否有同样简单的方法来引用和插入一个简单的 html 头文件,该文件将在任何 Page_Events 之前呈现?我试过 Page_PreLoad 和其他的都没有成功。要么根本没有获取代码,要么我遇到了同样的问题。

0 投票
1 回答
552 浏览

c# - AjaxRequest.get() 不接受来自 Response.Write() 函数的文本/Html

我正在使用AjaxRequestAjaxRequest.Get()中的方法。 以下是中的内联javascript
analysis.aspx

whengetAnalysis(type)调用analysis.aspx一切正常 - 正确提交 ajax 请求并正确发送响应。但最终值innerHTML仍然未定义。

以下是代码getAnalysis.aspx-

当我使用 google chrome 调试 javascript 时,我发现 value ofinnerHMTL是未定义的,尽管一切都很好。
所以我不明白为什么 AjaxRequest 类不接受来自Reponse.Write().

PS:我也试过Response.ContentType = "text/Html";Reponse.Fluch()
请提前指导我。

0 投票
3 回答
3307 浏览

c# - Response.WriteFile 两次写入内容

这是我的代码..

我正在使用上面的代码从一个位置下载一个 csv 文件。但令人惊讶的是,内容被两次或三次写入我下载的文件中,尽管实际上服务器上的文件并非如此。我正在写我在 c# 中的代码。上面的代码在本地机器上运行良好,但问题出在生产服务器上。

这是我的完整方法

并且上面的方法只在单击按钮时立即调用一次,所以这里没有任何循环的问题。

0 投票
1 回答
431 浏览

c# - TextBoxWatermarkExtender 在 Response.Write 后丢失文本

我正在将 asp.net 导出gridview到 excel 工作表Response.Write(*stringBuilder*),但是单击按钮时TextBoxes会丢失TextBoxWatermarkExtender文本。任何想法?谢谢。