• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5698
  • Last Modified:

The name 'response' does not exist in the current context

Im using the following snipet

httpContext.Current.Response.Clear();
        string FileName = Server.MapPath("/downloads/Resume.doc");
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileName);
Response.Flush();
Response.WriteFile(sSourceUrl);

I can't seem to find much info on the response object, primarily the basis behind the error: The name 'response' does not exist in the current context

0
Steve7423
Asked:
Steve7423
  • 2
1 Solution
 
apb2Commented:
Hi Steve

Why are you flushing the buffers before you write the source

string FileName = Server.MapPath("/downloads/Resume.doc");
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileName);
Response.WriteFile(sSourceUrl);
Response.Flush();

Try that

apb2
0
 
Steve7423Author Commented:
I changed the flush as you stated.  I suspect the problem is an object reference.  does the response object require declarations?

Ive tried httpcontext.current.response.contexttype and the httpcontext comes up with the same error.

I'm taking this method from other posts on EE as well as out of a book.  unfortunately things aren't explained well.

0
 
vinodhsomasekharanCommented:
Hai Steve,

I hope u r using C#.

The HttpContext is available in  the namespace System.Web.So try,

using System.Web;

HttpContext.Current.Response.Clear();

I hope u have used -- httpcontext.current.response.contexttype

I think the case is wrong... Try giving..

HttpContext.Current.Response.Clear();

just replace Response with  HttpContext.Current.Response and try..


Hope this helps u,

Regards
Vinu



0
 
apb2Commented:
I bet it's nothing to do with the response object and more to do with whate ever this is "sSourceUrl"

Could you post the code where you implement this?

and no the response object won't need any implementation as such

apb2
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now