开发者

How to display show message to user after Response.close?

开发者 https://www.devze.com 2023-02-28 18:19 出处:网络
In my asp.net web application i have to convert resx file to excelfile and then i should provide an option to download the converted file. I have done the download function using response.Addheader me

In my asp.net web application i have to convert resx file to excelfile and then i should provide an option to download the converted file. I have done the download function using response.Addheader method. Now i wanted to display statics to the user of how many keys are converted from resx file to excel file.

I have placed an label to display no of keys migrated but the code is not exceuted after response.end. Pls hel开发者_如何学Pythonp me to get this done

Thanks Rm


Short answer is that you cannot send some output once the response has closed.

Now to achieve what you want to do, you have to emit statistics along with link to download the actual excel file. For example,

  1. Convert the file and store results into file system. You should use some random key (such as guid) for generating the file name.
  2. Output statistics that you want to show to the user.
  3. In the same output, emit a start-up java-script that would redirect the browser to the url that will download the file generated in step1 - the file name key will useful for creating such URL.
  4. In rare cases where JS doesn't work or re-direct takes more time, The output from #2 should also contain a link that will allow user to download the file manually (the link will be accompanied with some friendly message)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号