prevent ASPX页面呈现 [英] Prevent aspx-page rendering

查看:193
本文介绍了prevent ASPX页面呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个正常的ascx页,其中包含HTML零部件以及code后面。这些元素都应该显示在正常条件下(作品)。

I got a "normal" ascx-Page which contains HTML-Parts as well as code behind. These elements should all be shown in normal conditions (works).

现在我希望能够设置一个请求参数,它会导致页面呈现祖不同。然后将其发送该网页上的信息不是人类可读的,但一台机器:

Now I want to be able to set a request-parameter which causes the page zu render differently. Then it sends the information on that page not human-readable but for a machine:

 string jsonProperty = Request["JSonProperty"];
                if (!string.IsNullOrEmpty(jsonProperty))
                {                    
                    Response.Clear();
                    Response.Write(RenderJSon());
                  //  Response.Close();
                    return;

这code是Page_ preRender内。
现在我的问题是:该字符串正确发送到浏览器,但在此之后,标准的HTML内容仍然呈现。

This code is inside the Page_PreRender. Now my problem is:The string is correctly sent to the browser but the "standard" html-content is still rendered after that.

当我删除Response.Close();评论我收到一个ERR_INVALID_RESPONSE

When I remove the "Response.Close();" Comment I receive an "ERR_INVALID_RESPONSE"

任何线索如何解决此问题,而无需创建一个额外的页面?

Any clue how to solve this without creating an additional Page?

推荐答案

尝试添加的 到Response.End()

Try adding Response.End()

发送所有当前缓冲输出到客户端,停止页面的执行,并引发EndRequest事件

Sends all currently buffered output to the client, stops execution of the page, and raises the EndRequest event.

此外,作为@Richard说,添加

Also, as @Richard said, add

context.Response.ContentType = "application/json";

这篇关于prevent ASPX页面呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆