Custom ActionResult for multicast HTTP response?

I would like to respond to an http request with both a txt file and an html page. Thus, the client can save the file and view a summary of the contents of this file on the html page.

Since the file is generated on the fly, I have to use state management on the server to create a summary of the second request. I would like to avoid this and wrap it in one answer.

What does a custom ActionResult look like?

+4
source share
4 answers

It was also discussed here at SO .

I answered like this:

No, multi-user attachments for downloading (for example, via email) are not supported for security reasons. This is called a boot boot.

Please note that Gmail handles this by dynamically zipping files. You too. http://forums.asp.net/t/1240811.aspx

I do not think any modern browser supports multipart / mixed.

+2
source

You can send XML with reference to the XSLT stylesheet. The browser can perform the conversion and display the resulting HTML output.

And the user can simply execute "File-> Save As ..." to save the XML file.

0
source

Why not make the summary like a normal HTML view and provide a link under that summary that points to a separate ActionResult that returns binary data ...

public ActionResult SendFile(int id) { File file = FileRepository.GetFile(id); byte[] fileData = file.FileData.ToArray(); return File(fileData, file.FileMimeType, file.FileName); } 
-1
source

I did a few searches on this topic, and, to my surprise, it seems that people have already done this. I found a description here , but it does not provide a public test URI, so I could not verify the behavior of the browser on this. It also mentions the decision to send the archive file to the client. But I guess that is not what you are looking for, right?

Here 's another article showing an example with multiple answers. Unfortunately, the demo URI does not seem to work anymore.

So the situation is this: HTTP response responses can be executed. There are client (several) libraries for processing them in the application code. It is necessary to check the behavior of the browser ( here is the voice ). Using this feature seems experimental and can only be recommended. You can control both ends of the connection to fix compatibility issues.

-1
source

Source: https://habr.com/ru/post/1286592/


All Articles