Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an ASP MVC Equivalent for PHP's require_once()?

I'm wondering if there is an ASP.Net MVC equivalent to PHP's require_once() function.

Lets say I need to call RenderAction to a particular action twice. However, inside the view that is rendered from said action, I need to print out some init scripts but only once.

Is there an easy mechanism to do this? Should a flag be set in the controller and then passed into the view?

Thanks for any help you can provide.

Edit Thanks for the responses. I know I can do this through the controller or temp data or some mechanism like that but wasn't sure if there was anything built into .NET MVC that would have done this for me automatically.

like image 234
Jonathan Avatar asked Nov 04 '22 15:11

Jonathan


1 Answers

I am not aware of such equivalent.

Should a flag be set in the controller and then passed into the view?

That seems like a good way. The flag needs to be passed as argument to the controller action when using the RenderAction helper.

like image 155
Darin Dimitrov Avatar answered Nov 15 '22 04:11

Darin Dimitrov