I am facing a problem while working with xml file in asp.net mvc 5. I need to load a xml file. and read the xml data in different views. which have individual controller too. I have loaded the xml file successfully. But I can not catch the idea how can I pass the xml file data to other controller. Like I have a Controller for loading the xml file. And I have another controller to read the xml data. Can you guys give me the idea how to do the rest work?
-
You can always serialize the XML to an object and save it to Cache or a Session variable. Or you can make a base controller and make sure that all of your project controls inherit from it. Inside the base controller, place all of your code for handling the XML in it on the "ActionExecuting" function.Kevin B Burns– Kevin B Burns2016-09-21 15:16:45 +00:00Commented Sep 21, 2016 at 15:16
Add a comment
|
1 Answer
Sorry for my late answer. The problem was that I did not get full directory path to read the file. Then I created a cache memory to save the file and read it. And to read data in several controller I used like, Session["abc"] = "asas"; And to get this information in other controller, Viewbag.abc = Session["abc"];