Prasad Bhagat

Prasad Bhagat

  • NA
  • 516
  • 235.5k

name "Response" does not exist in the current context

Dec 3 2015 6:57 AM
Dear all,
 
 
Implemented a method that will export data from html file to excell using asp.net c#.that could working fine .but i need to access that method into windows forms .am adding dll to my windowsforms solution after accessing the method running the freame .trying to call the method where i have implemented method with web responce .there am getting these above error .if i replce with HttpContext also getting invalid name its showing .please i want to develop a application that was exports the data from html to excell.
 
 
 here my asp.net c# code bellow.
 
 
 
 
public void exportOne()
{
string fullPathnew = "D:/WebApplication4/WebApplication4/BOM.htm";
// string html = File.ReadAllText(Server.MapPath("~/" + fullPathnew));
// HttpContext.Current.Response.Clear();.
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Buffer = true;
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + "Export" + ".xls");
System.Web.HttpContext.Current.Response.ContentType = "application/vnd.xls";
System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); // not necessarily required
System.Web.HttpContext.Current.Response.Charset = "";
// System.Web.HttpContext.Current. this.EnableViewState = false;
System.Web.HttpContext.Current. Response.Output.Write("~/" + fullPathnew);
System.Web.HttpContext.Current.Response.End();
}

Answers (1)