asp.netiis-7.5integrated-pipeline-mode

Response.write in IIS integrated mode


I have been working on an asp.net project that must work in integrated mode on IIS 7.5.

When I use Response.write("sometext"), IIS wraps my texts with waste HTML tags.

Look at this code:

protected void Application_BeginRequest(object sender, EventArgs e)
{
        Response.Clear();
        Response.ClearContent();
        StringBuilder sb = new StringBuilder();
        sb.Append("<html>");
        sb.Append("<head>");
        sb.Append("</head>");
        sb.AppendFormat("<body>");
        sb.AppendFormat("some text");
        sb.Append("</body>");
        sb.Append("</html>");
        Response.Write(sb.ToString());
        Response.End();

}

I exepct receive this from server:

<html>
<head>
</head>
<body>
sometext
</body>
</html>

but the server gives me this:

 <html> 
 <head>
 </head>
 <body>
 <pre>
      <html><head></head><body>sometext</body></html>
 </pre>
 </body>
 </html>

What's the problem??

Application works fine in VS web developer server or IIS ( in classic mode ).


Solution

  • after two days accidentally i founded if use Response.Flush(); command the IIS can't wrap the response