Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:40:36+00:00 2026-06-13T07:40:36+00:00

I want to be able to output a simple string as text rather than

  • 0

I want to be able to output a simple string as text rather than the HTML page when a set of criteria are met. I am currently using:

Protected Sub OutputString(ByVal Str As String)
    Dim bytes() As Byte
    bytes = System.Text.Encoding.UTF8.GetBytes(Str)
    Response.ContentType = "text/plain"
    Response.OutputStream.Write(bytes, 0, bytes.Length)
    Response.End()
End Sub

This works great and does exactly what I want, however, the Response.End() generates exceptions and (I believe) should be avoided where possible.

I suppose I could use a separate “empty” page for this code but its more of a work around than a solution. Also, someone said something about over riding the HTML output behaviour (can’t remember where now).

I would be very grateful if someone could tell me the best method.

UPDATE:
I found this link :
Response.Redirect(url) ThreadAbortException Solution

It recommends using HttpContext.Current.ApplicationInstance.CompleteRequest() and over riding the functions that render the page:

Dim DoNotOutputHTML As Boolean = False

Protected Overrides Sub RaisePostBackEvent(sourceControl As IPostBackEventHandler, eventArgument As String)
    If DoNotOutputHTML = False Then
        MyBase.RaisePostBackEvent(sourceControl, eventArgument)
    End If
End Sub

Protected Overrides Sub Render(writer As HtmlTextWriter)
    If DoNotOutputHTML = False Then
        MyBase.Render(writer)
    End If
End Sub

You can then choose whether or not to output your html page by setting the variable DoNotOutputHTML.

The only problem I have with this is that any code after the CompleteRequest() still executes. I can work around this by restructuring my code although it would be neater (less if/else blocks) if I didn’t have to, like I don’t with response.end()

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:40:38+00:00Added an answer on June 13, 2026 at 7:40 am

    In the end, I just used Response.End() and ignored the exceptions. Seems to work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

to export some data i want to be able to generate an html output.
I have large String variable named text . I want to be able to
I'm using TinyMCE to let users edit and format text, output is html code.
I want to be able to test my cakephp web page using the localization
I want to be able to output the number of times the second-position numbers
I want to be able to run netstat -n and grab the output somehow
I'm using LaTeX and BibTeX for an article, and I want to able to
Say I want to output a huge set of search results, as XML, into
I've got a simple web-page that generates a CSV file that I want the
I want to be able to pass my input files and output files into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.