Is there any way to set the view file name as an attribute on top of Action ?
ex:
[ViewName("~/Views/CustomerInformation.cshtml")]
public ActionResult ViewCustomers()
{
//
}
purpose is to change the view file dynamically at run time.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Of course, you could override the
OnActionExecutedmethod and replace the original view name that was used by the one specified in the action filter:and then you could just return a dummy view:
But I wonder what the practical application of your custom action filter is when you could directly write:
You doesn’t seem to be bringing much value with this custom action filter to what the framework already provides.