I have searched SO for my scenario but no success. I have a problem statement that I need to show different kinds of reports based on user input. And the reports are varied based on logged in user's location. So, I am storing the view (cshtml) code in DB and want to return the code by calling stored procedure passing required parameters. Here, I do not know how to bind the model to the returned view string (came from DB). Can I write custom HTML helpers and solve this? Is there any other way to achieve this? Any kind of help would be appreciated. Thank you.
Asked
Active
Viewed 236 times
0
1 Answers
0
There are a couple questions with answers already on SO for this. This answer to this similar question has four links to other answers:
Load Razor Views From Database in ASP.NET MVC 5
In addition to that, I would add that you can also accomplish this with RazorLight, which is a 3rd party library. The author offers a specific example of a custom view source using a database:

Bryan Lewis
- 5,629
- 4
- 39
- 45
-
Thanks, I will go through them. I will post once I get the solution. – Mahesh Kudikala Apr 10 '19 at 08:02
"at"Model.Name
";ViewBag.HtmlCode = str;return View();} But I am getting output like this: "at"inherits System.Web.Mvc.WebViewPage "at"model WebApplicationDynamicViewLoad.Models.TestModel "at"Model.Name – Mahesh Kudikala Apr 10 '19 at 12:39