c# - 呈现没有 html、body 标签的 .aspx 页面

标签 c# asp.net

我有一个测试页 Test.aspx,下面是我在 Page_Load 函数中的代码。

Response.Write("test");

当我执行这个页面时,我可以看到 html 输出“测试”以及 html, body 标签在里面。

我应该怎么做才能使输出只有文本“test”,而没有 body、html 标签?

请提出建议。

最佳答案

您可以尝试使用此代码 - 基于 ContentType = "text/plain";

Response.Clear();
Response.ContentType = "text/plain";
Response.Write("Only text is printed");
Response.End(); 

关于c# - 呈现没有 html、body 标签的 .aspx 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12477001/

相关文章:

.net - 如何使虚拟 URL 指向部署在 IIS 上的 asp.net 中的 .aspx 页面? (最好没有 IIS)

c# - 无法反序列化当前的 JSON 数组(例如 [1,2,3])。 C#,无法找出错误

c# - 我如何使用 MS Moles 从地鼠那里引发事件?

c# - 无法转换类型为 'System.Data.Entity.DbSet` 的对象 1[ModelName ]' to type ' System.Data.Entity.DbSet'

c# - 如何在自定义 AuthorizeAttribute 中允许 [Authorize]

c# - AuthorizationCodeReceivedNotification 未将对象引用设置为对象的实例

jquery - ASP.NET - jQuery ajax 调用队列而不是同时运行?

c# - 如何测试 8 :00 PM is valid prior to 12:00 AM?

c# - ASP :GridView not getting info from SqlDataAdapter with Stored Procedure

c# - 什么会生成WebServiceRef Reference.cs文件?