Help with asp.net mvc and ViewData in MasterPage -
Before availing the data that is run in the main page of my site before each view of each controller I created An application for the controller that sets the data on its constructor ... The problem with this approach is that the videotapes I have to pass are the URL of the profile which is the image of the currently logged in user.
[Author (roles = "Administrator")] Public Abstract Class Administrator Controller: Controller {Personal IPortal Administrators Administrators _ Serving Administrator Administrator; Public Administrator Administrator () {_servicioPortalAdministrator = New PortalManagement Services (); See data ["affiliate"] = _servicioPortalAdministrator.getAssociates (); See data ["picture"] = _servicioPortalAdministrator.GetPic (); Public Administrator Administrator (IPORA Administrator Service Service) {_servicioPortalAdministrator = service; }}
And so my companies are the controllers who get from the administrative controller, now do not have to set all those data to each view call.
[Author (roles = "administrator")] Public class companies: Controller: Administrator Admin {Private ICompanias Services _ Service; Public Companies () {_service = New Companion Services (New ModelStatePaper (this.ModelState)); } Public companies Controller (ICompaniasServices service) {_service = service; }
The problem is:
When I try to manually use the Controller controller without logging into the GetPic method, Not able to receive picture url reason no one is logged in. And this method is calling in spite of the Authorize attribute .... So now, even if the image is logged in ViewData for "unknown" / P>
Some of this code is not mine .. I head I have searched the bug, but I know how to fix it.
if (User.Identity.IsAuthenticated) {ViewData ["picture"] = _servicioPortalAdministrator GetPic (); } And {...}
Can it use something?
Comments
Post a Comment