How to Refresh page after Response.End - asp.net

In my ASP.NET application on a button click i am writing a .pdf content dynamically and the I am allowing to download for a User
Now to download i used Response.End() and need to refresh a download count on a page
But due to Response.End it is not happening
Please suggest

And it will never happen - You can not refresh page after Response.End
The way you download the files is not the best one. Use a handler for the download files and a simple anchor to that file.
Examples / Similar :
file download by calling .ashx page
What is the best way to download file from server
Hide modal window after Response.End() in asp.net

Related

download file and redirect page in asp.net

I want to write a program where after button click page will be redirected and one pdf file will be download. I am writing the following code under the button click event. but it is showing the error.
Response.TransmitFile("Filename")
Response.Redirect("~/Redirect.aspx")
Response.End()
It is impossible, because file download will get HTTP status 200 (with file in response). Redirect is 301/302, but cannot contain file in response.
Moreover when modern browser receive a file it does not change the current URL.
If you really want to have such effect you have to create something on client side. For example you can use jquery file download which has events after download and on error. More on examples page

force reload of aspx page from silverlight xaml

I've a Silverlight application that is called from a asp .net project. I have a link in the silverlight project that brings the user back to the asp.net project. I do not want this to happen in a new window.
At the moment, it returns me to the cached page. I want to force a reload of it.
Currently onclick event of the link invokes the following code:
HtmlPage.Window.Navigate(new Uri("http://ipaddress/menu.aspx"));
Any suggestions on how I could enforce menu.aspx to reload when called?
I found a solution..
SOLUTION
HtmlPage.Window.Navigate(new Uri("http://ipaddress/menu.aspx?"));
This results in the page being reloaded....
Try using:
HtmlPage.Document.Submit()
It should work if your .aspx target page you wish to reload is the current page.

file transfer through iframe not propagating

I'm still rebuilding old ASP to new and iframing certain things that take up too much time.
I'm stuck at a search function that normally returns an excel file (browser asks save or open). the result page for this is now iframed but it does not seem to propagate the file anymore, so no more save-file popup.
I must add that this iframe is being filled through a custom httphandler that posts to the old pages based on certain criterie, the searchcriteria in this case.
does anyone have an idea on how I could make the excel propagate once again?
The way to ensure you get a save-file prompt and not a page, do the following:
Open the file in ASP
Send the MIME header for Excel
Stream out the file from ASP
You may also choose to hold the files outside of the web root so they cannot be downloaded directly.
Here are a few examples: 1 2 3
This may come in handy as well:
How to output an Excel *.xls file from classic ASP
It *seems* like a security issue. What happens if you open the URL which is being loaded in the IFrame in a new browser? To confirm it, you can try opening the URL, and see what happens.

File uploading in AJAX updatepanel without full postback

I have a update panel, in the update panel I have fileupload control and button control, On button click, I need the file that I have upload in the fileupload control in updatepanel.
Exact scenario, I have 8 tabs on page, each tab contains too much information, One of the tab is Attachment, when user click on Add New Attachment Modal Popup shown, Modal contains detailsview in Updatepanel and in the detailsview I have fileupload control, when user hit save button, detailsview inserting event fired, In the inserting event I need the file that I have upload.
Please Note, My page is heavy and I don't want full postBack.
Does anyone have solution of this issue?
Advance thanks for your kind help.....
For solve this problem, Please see the following step.
Add ajax-upload to your detail view.
iframe-based uploader like Resource#1.
Silverlight-based & Flash-based uploader. I like this technique because it doesn't require any server-side script for display current upload status. But in HTML5, you can create this without using any web browser plug-in.
Commercial uploader like Resource#2. that use hidden iframe for uploading.
Upload file to temporary location.
System response the temporary location. Next, client keep temporary location in hidden input in detail form.
Keep temporary location with session_id. You can store it in database or Session variable depend on your framework.
When you click on the save button, the system will move the files to their real location
Note. System will automatically delete the expired file from the temporary location.
Resource
ASP.NET File Upload with Real-Time Progress Bar
ASP.NET File Upload like GMail (Commercial)
Update
After almost one year, I just found a great 3rd-parties control for this question. This is an open source plug-in of jQuery. It name Plupload that allows you to upload files using HTML5, Silverlight, Flash or normal forms and it provide some unique features such as upload progress, image resizing and chunked uploads.
You can try & test Plupload by click here.
Can't be done without co-operating binaries being installed on the client. There is no safe mechanism for an AJAX framework to read the contents of a file and therefore be able to send it to the server. The browser supports that only as a multipart form post from a file input box.
The problem is with the way the HTML file upload control works, has nothing to do with ASP.net, for the file upload control to work you need a full post of the form data. You can only simulate that your are not doing a full postback, by doing all the operation in a hidden iframe that does the actual uploading
The sites you see that do provide this functionality generally use flash or an iframe so that the postback occurs in the iframe and gives the illusion of an ajax request.
HTH
OneSHOT
I've tried swfupload (http://swfupload.org/), but do keep in mind that you have to jump through hoops if you're using forms authentication with non-IE browsers. This is apparently a flash bug, and it's not fixed in flash 10. I decided against using it in our framework because of this bug, but it was otherwise a great product.
I recommend the uploader widget from YUI. See http://developer.yahoo.com/yui/uploader/
I think you could use it to accomplish your goal. Your javascript would need to fetch the file back down to the client from the server after it completed its upload. But the page would not refresh--the upload is through flash and a hidden iframe. The download to show the file's contents to the user would be via ajax.
If the user does not "approve" the upload, then simply make another ajax call to the server to delete the file.

Problem using the ASP.NET FileUpload control in an UpdatePanel?

I'm running into an issue where I have a FileUpload control in an UpdatePanel. When I attempt to save changes and upload the file, no file is found. If I remove the UpdatePanel everything seems to work fine.
Any ideas why this might be happening? And is there a work-around?
To upload a file you need to perform a full ASP.NET page postback, it does not operate over the partial postback method.
You'll need to register the button which "uploads" your file as a PostBackTrigger of the UpdatePanel's triggers.
There are lots of free (and non-free) AJAX file upload solutions, or you can easily create one, it's just a matter of putting your file upload control within an iframe and submitting the iframe page back to the server. It isn't really ajax, but it gives a visual impression of AJAX.

Resources