代码之家  ›  专栏  ›  技术社区  ›  rlandster

希望C#ASPX页面生成纯文本而不是HTML

  •  2
  • rlandster  · 技术社区  · 14 年前

    default.asp.cs . 当我建立一个文件的项目 default.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CSRValidationConnector._Default" %>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div> 
        </div>
        </form>
    </body>
    </html>
    

    当我提出我的web请求时,这个页面的大部分内容都会返回。

    Response.Write 来电 default.aspx.cs ?

    2 回复  |  直到 14 年前
        1
  •  4
  •   cgreeno    14 年前

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CSRValidationConnector._Default" %> 
    

    在你的代码隐藏页面 Response.Write("String")

        2
  •  4
  •   Ranhiru Jude Cooray    14 年前

    Response.ContentType是您要查找的内容:)

    Response.ContentType = "text/plain";