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

  • Home
  • SEARCH
  • 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 6700803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:51:30+00:00 2026-05-26T06:51:30+00:00

In a code-behind I have a method that consists of the following: Response.Clear(); Response.ClearHeaders();

  • 0

In a code-behind I have a method that consists of the following:

        Response.Clear();
        Response.ClearHeaders();
        Response.ContentType = "xxx";
        Response.AppendHeader("Content-Disposition", "xxx");
        Response.AppendHeader("Content-Length", xxx);
        Response.BinaryWrite(xxx);
        Response.Flush();
        Response.End();

Now, this code will be used in a few different places. The code will be identical in the various places it is used. Only the file name and byte array will change and those are parameters passed to the existing method.

My question is, how do I pull this code out from the current code-behind and place it in a “Utilities” class. I tried copying and pasting the code into the class where I’d like it to reside by the Response object is giving me some problems (Cannot resolve symbol ‘Response’). I tried instantiating an HttpResponse to return but the constructor only takes a textwriter and upon further research, MSDN says I shouldn’t be doing that anyway.

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-05-26T06:51:30+00:00Added an answer on May 26, 2026 at 6:51 am

    Use HttpContext.Current.Response, which will work in your Utilities.cs

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

Sidebar

Related Questions

I have a web application that will need to access code behind methods as
In code-behind of an ASP.NET page I have this method: public string TestFunc() {
I have Dropdownlist on my page and its selectedindexchanged method created in code behind
I have some code that I am putting in the code-behind of a master
I am trying to have a method in my code behind at runtime add
I have a member in the WPF code behind that is disposable (meaning it
I have no code behind and the above error keep prompting on INSERT. The
I have below code behind in c# if (Session[cmpDictionaryTitle]!= null) { downloadLinks.Text += @<li><a
I have AutoEventWireup=true and in my code behind protected void Page_Init(object sender, EventArgs e)
I have an ASP.NET page with code-behind in VB.NET. On the ASPX page I

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.