How to return a file and strongly typed data at the same time?

I am using asp.net mvc 1.0 and I want to return an XML file, but I also want to return strongly typed data to update some fields.

Like an XML file, it will contain users that have not been inserted into the database. So I want this to appear as a save dialog that asp.net mvc return file () will do.

However, I also want to return to the page, for example, such as the number of users who could not be added, how many users added, etc.

So, I want to use scafolding with the class file I want to pass. If it was a view, I could pass it as an object model, but I do not see the parameter for this in File ().

I also do not want to save the xml file to the hard drive, which I want to do with memory. So you have a link that will appear on the page to download the file and show that the data I want will not be desirable.

+3
source share
1 answer

I could be wrong, but I think you will need to use JavaScript for this. What you are trying to do is an HTTP limitation and from my understanding of HTTP, you can only return one file type for each response, as the protocol is request->response.

MVC XML ViewData. , JavaScript window.location URL- ( ).

, JavaScript, , .

:

, gracefully , :

JavaScript

+1

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


All Articles