teenup
teenup

Reputation: 7667

Deriving Controller from a BaseController, then Action methods do not execute and response is blank

I wanted to create a CurrentUser object to be accessible in every Action of Controller, I initialized it in Constructor but User.Identity was not available in Constructor. I followed the following link on stackoverflow:

Defining a User with User.Identity.Name in controller constructor

But after inheriting my Controllers from BaseController, my Action methods are not even executed, the execution stops at Execute of BaseController and I get blank pages in the browser.

Upvotes: 1

Views: 442

Answers (1)

smartcaveman
smartcaveman

Reputation: 42246

I looked at the Execute override in the linked post. It is missing the call to base.Execute(context). This means that there is no call being made to Controller.ExecuteCore(), which means that no call is being made to ActionInvoker.InvokeAction(context,actionName), which is why your action methods don't execute and your response is blank.

Add base.Execute(context) to the end of your Controller.Execute() override.

Upvotes: 4

Related Questions