Simple question. I must be totally wrong but I thought worth asking this question.
Is accessing ViewData[“Message”] within the View correct according to separation of concerns described in MVC?
For example, in Controller:
ViewData[“Message”] = “Display this message”;
Within View we call
<%= ViewData[“Message”] %>
The alternative (does not violates Separation of Concerns) is to have the Message set in the view model.
For example in Controller:
UserViewModel.Message = “Display this message”
Within View we call
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<UserViewModel>" %>
<%= Html.TextBox("Message", Model Message)%>
Any ideas greatly appreciated.