Link to home
Start Free TrialLog in
Avatar of Steve7423
Steve7423Flag for Canada

asked on

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

Avatar of apb2
apb2
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Steve7423

ASKER

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.

ASKER CERTIFIED SOLUTION
Avatar of vinodhsomasekharan
vinodhsomasekharan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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