简体   繁体   中英

Is it possible to "batch" generate views in an ASP.NET MVC Web Application C#?

Basically, I have a C# MVC Web App, with Controllers that contain methods like this:

public ActionResult A (filters)

public ActionResult B (filters)

public ActionResult C (filters)

Each of these takes in filters, fills a list in the model using data (SQL from Stored Procedure), and generates a View (using DataTables). As far as the user sees, they click a button (A, B, C, etc.), select their desired filters, click "enter", and this process runs, generating the View (which is basically a report). The user can repeatedly go through this process, and each of these views/reports is generated above the other(s) on the page (they can scroll up and down). What I want to do, is have a different button --> filter page where they only select a "batch" of these reports they want generated. So if the user selects the option 'Batch 1', it generates Report A (with filters I define), then generates Report B (pre defined filters), then generates Report C (pre defined filters), ideally without any addition inputs from the user being needed.

Initially, I had been hoping to have some sort of "Super Controller", that would call ActionResult A, which would run through its process and generate the View. Then, instead of ending, it would return back to this "Super Controller" where it would then Call ActionResult B and run though the process, generating the view, etc. However, I'm now wondering if this is even possible in MVC. I do feel like something along the lines if this is the most "logical" solution, but it doesn't seem like Controller will let you implement something like this (at least in the ways I've tried). I've also tried to implement Tasks, but the only thing I was able to do with that was create 1 enormous view/report, which won't work for what I need (which is to generate lots of individual views, which each contain the ability to export to PDF, etc. via DataTables). If anyone could point me towards some sort of solution/ideas to do this it would be greatly appreciated. Please let me know if more info is needed.

You should see actions from controllers as entry points for your http requests. So, each request is mapped to one action, so this should not be possible, and you should not think of doing it this way.

It would be better to have on action that receives the data needed to be able to generate the uber report.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM