Reputation: 1337
I've been trying to convert my site that currently uses .aspx view pages to Razor. Everything works fine except I'm stumped on how to deal with the code behind on the master page.
I have some code in the "OnInit" event and don't know where to put it now.
Any ideas?
Upvotes: 3
Views: 2641
Reputation: 23060
You could use the _ViewStart.cshtml razor page. It will execute before every view is rendered.
Depending on what you're trying to do you could also create a ActionFilterAttribute for your controller which will execute a method before rendering the view.
Upvotes: 4