In ASP.NET, if a file was downloaded on a page that was protected by SSL, through a server-side postback that writes to HttpContext.Current.Response.OutputStream, is the transmission that file ALSO protected by SSL?
Does anyone know how to use httpcontext.response.transmitfile or any other httpcontext function to download a file from a network drive instead of local drive? When I tried to use context.Response.TransmitFile(DownloadPath) to download files, the DownloadPath has to be local drive. If it's a network drive, the download failed.
Does anyone know how to use httpcontext.response.transmitfile or any other httpcontext function to download a file from a network drive instead of local drive?
When I tried to use context.Response.TransmitFile(DownloadPath) to download files, the DownloadPath has to be local drive. If it's a network drive, the download failed.
There are files stored in sql server (datatype of column is varbinary in the database).
each record is in one record in that table (FILE_TABLE).
And there is another table (PATH_TABLE) to store the files paths.
for example,
when the user download the folder A (select an item on the tree and click a button on the client side),
there is one sub-folder B and two files A-1 and A-2.
in folder B, there is two files B-1 and B-2.
then, at the code behind (server), the server will get the files from the database and convert them (including the files and subfolders) to a .zip file (or other compressed files)
and then write a response (using the method HttpResponse.BinaryWrite(Byte[] xxx) )
to client side and let the user download.
after the download, the user can extract the compressed file and the structure of the folders and files keep unchanged.
I am trying to change the text of a asp:textbox and collapse some ajaxToolkit:CollapsiblePanelExtenders within some ascx controls on my page as well as output a dynamically generated file. I have no problem collapsing the CollapsiblePanelExtenders and changing the text of the textbox from the codebehind or outputting a file. The problem arises when I want BOTH of these events to happen on the same postback. Unfortunately using Response.Write negates all of the other changes to the page.
As I have migrated Web Application from 3.5 (VS 2008 ) to 4.0 Vs (2010)
Now i am having problem with Response.Redirect
As I in .aspx pages i have found the following solution and it is working fine.
old Code with is not Working in Vs2010
[code]....
But now I need to Redirect from the class librarySo can any one guide me on the same.. i can i redirect .. AS I have try with HttpContext.Current.Response.Redirect(strURL); but it is not working.
I've a gridview which I am rendering to a html text writer and allowing clients to download as an excel spreadsheet using Response.Write. I'm using AJAX in my website now and suddenly it stopped working. This is the code I'm using
public static void Convert(DataSet ds, HttpResponse response) { try { //1. declare filename to export string filename = "export"; //2. clear response object response.Clear(); response.Charset = ""; //3. set response mime type to excel response.ContentType = "application/vnd.ms-excel"; //4. prompt user to download the file response.AppendHeader("content-disposition", "attachment; filename=" + filename + ".xls"); //5. create a string writer StringWriter stringWrite = new StringWriter(); //6. create html writer which uses the string writer HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //7. instantiate a gridview GridView gv = new GridView(); //8. set gridview datasource to the dataset gv.DataSource = ds.Tables[0]; //9. bind gridview gv.DataBind(); //10. tell the gridview to render itself into htmltextwriter gv.RenderControl(htmlWrite); //11. output html response.Write(stringWrite.ToString()); //12. end response response.End(); } catch (Exception ex) { string str = ex.Message; } }
I've found that Response.Write doesn't work with AJAX. Are there any alternatives to this?
I currently have an asp.net page which a loggd in user goes to and theres a bunch of dynamically generated links to zip files that he or she owns and can downloads.Currently they click download and I have no way of knowing if it completes succesfully etc so can't log it. I do log the attempt.Is there are good download manager or solution I can use so they will have progress bars on the site, they can queue multiple ones up and most importantly I can track failed and successful downloads.
I have a web form, that needs to save the data that the user enters, into a file and on the client pc, that will also be able to read from the saved file and repopulate the fields at a later time. No files will be saved to the server side, so I expect streaming needs to be involved at writing time.
I decided XML would be an easy way to do this, but I'm stymied on methodology. XML documents? XML Writers?
I'm stumped on the right search terms to even get what I want.
Error 1 'Response' is an ambiguous reference between 2 references that have a Response.Neither is the one I need,how do i reference the Response that write the file?
I have a static class with serveral static methods. In these methods, I'm trying to access the current thread's context using HttpContext.Current. For example:
var userName = HttpContext.Current.User.Identity.Name;
However, when I do that, I receive a NullReferenceException, the infamous "Object reference not set to an instance of an object."
I'm working on some code that generates an Excel spreadsheet server-side and then downloads it to the user. I'm using ExcelPackage to generate the file.
The generation is working just fine. I can open the generated files using Excel 2007 with no issues. But, I'm having trouble downloading the file with Response.TransmitFile().
Right now, I have the following code:
//Generate the file using ExcelPackage string fileName = generateExcelFile(dataList, "MyReportData"); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.ContentType = "application/vnd.xls" Response.Charset = ""; Response.TransmitFile(fileName);
When Excel 2007 opens the file downloaded as above, it gives the "file format doesn't match extension" warning. After clicking past the warning, Excel displays the raw xml contents of the file. If I change the file extension, like so Response.AddHeader("content-disposition", "attachment;filename=FileName.xlsx"); Excel 2007 gives an "Excel found unreadable content in the file" error, followed by a dialog that offers to locate a converter on the web. If I click "no" on this dialog, Excel is able to load the data.
I've also experimented with different MIME types, like application/vnd.ms-excel and application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, combined with file extensions of .xls and .xlsx. All combinations result in one of the two behaviors mentioned above. What is the correct combination of file extension and MIME type to use in this scenario? What else could cause this failure, other than an improper MIME type or extension? FYI, this is occurring with Visual Studio's built-in development web server. I haven't yet tried this with IIS.
I've recently developed a web user control that lists a series of reports. When the user clicks on the report it serves back a CSV file download in the response stream using the following code:
The code initially worked fine in all browsers. Then the client put a requirement to use SSL for the site. As part of this I introduced a global handler to update the protocol from HTTP to HTTPS for all requests as follows:
However, since securing the site using SSL the CSV file downloads no longer work for IE although they do continue to work for Firefox / Chrome / Safari.
Is there something I am missing in the headers that is unique to IE in order for the file response to work correctly?
The message I receive from IE is:
"Internet Explorer cannot download Reports.aspx from .... in ......
Internet Explorer was unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."
UPDATE:
Here is some example fiddler output coming back from the page request which looks like it's serving correctly. Why doesn't IE understand that it's just been served a file?
HTTP/1.1 200 OK Date: Tue, 09 Nov 2010 14:23:50 GMT Server: Microsoft-IIS/6.0[code].....
I have following function which is called from a button click event
[Code]....
I am creating a zip file on the fly and wanted to download this file.Problem is that in Internet explorer when I click the button the download accelrator comes with file name as my page saying resume opendialogueif i click open then DAP window close and normal windows download manager comes but the event of my button fires multiple time?I don't know what to do with it
I have some information I am pulling from my db into a table. Can anyone direct me to a tutorial that shows how to dynamically create a file and allow a user to download that file with the table contents. All this must be dynamic.
I am using a gridview to display (open or save) files that have been uploaded into a SQL 2005 server. I have a templatefield within the gridview that contains a linkbutton that does a postback to GetUploadedFile.aspx that then fires the response.binarywrite() code. The code seems to work fine and opens/saves the files correctly. But once this has completed and I try and click on another button on the page, instead of doing the appropriate action it re-fires the getuploadedfile.aspx binarywrite code and opens up the "Open/Save/Cancel" dialog again.
But if I do that the current page will be erased and return blank to the user.
Other examples says to create "download.aspx" and request it by javascript, but on a this new page I won't have access to the ViewState data of the first page.
The point is, how can I create a file, launch the download and don't lose the current page status?
I am using the code below to enable clients to download a .csv file from my server.
The problem I am having is that when the file is saved to the client computer the file name is prefixed and suffixed with an underscore which leads to a file type of .csv_ which is obviously not a recognised file type.
How can I strip the underscores from the file name at the transmit stage?
Dim FileName As String = LstBox1.SelectedItem.ToString Dim FilePath As String = "~/temp" & FileName Response.Clear() Response.ContentType = "text/csv" Response.AddHeader("Content-Disposition", "attachment; filename=" & FileName & "") Response.TransmitFile(FilePath) Response.End()