There is a need to do the program today.
Want a controller to invoke the view of the B controller. is to share a view interface, different places in the JS to judge the writing.
Thought of using return Redirecttoaction (ActionName, Controllername, Value);
Jump to the controller view that you want to jump to in the a controller.
When it is written, it is found that the viewbag.title of the view is still the title of the B controller when the view is loaded. You want to change the title of a view based on a different controller.
How do you change it? Just started to use ViewData to pass a tag, mark the page to change the title, but found that ViewData is not implemented, because ViewData can only be passed in the current controller value
And can not be transmitted in different controllers, the last choice with TempData, TempData can be in different controllers in the value, the role and the same as the session, the difference is that the TempData will be automatically released after use
The session is not automatically emptied and can only be manually emptied.
At last, the TempData is used to carry out the value, in the foreground of the interface to judge the display of different viewbag.title
Above
Different controllers use one view