I'm actually working on Asp.Net MVC project, and I have a problem to load a view from another using Html.RenderAction method. And this is only when I try to access the view when the solution is deployed on a Distant Server.
Here is the code I use :
I have an Index.cshtml view that looks like this :
<section class="panel panel-default"> <section class="panel panel-default"> <header class="panel-heading">@Html.Localize("SmartContactMessages", "CustomersManagement")</header> <div class="row wrapper"> <div class="col-sm-5 m-b-xs"> <a class="btn btn-primary" href="@Url.Action("Create")"> <i class="fa fa-plus text"></i> <span class="text">@Html.Localize("SmartContactMessages", "Create")</span> </a> @*<a class="btn btn-danger" href="#" onclick="DeleteTerritories()"> <i class="fa fa-trash-o text"></i> <span class="text">@Html.Localize("SmartContactMessages", "Delete")</span> </a>*@ </div> </div> <div id="CustomerListZone"> @{ Html.RenderAction("List"); } </div>
As you can see I Use Html.RenderAction method to load the view "List".
List.schtml, displays a table with differents enterprises. (No need to display its code)
In my controller I have the following code :
[Authorize(Roles = RoleConstantes.AdminGlobal)] public ActionResult List() { Logger.Info("List method enterred"); EnterpriseListMessage message = null; WcfService<IEnterpriseServiceContract>.Use(Logger, e => message = e.GetAll()); var smartContactEnterpriseListViewData = new SmartContactEnterpriseListViewData { CurrentPage = 0, ItemPerPage = 10, NbPage = 1, Total = 2 }; if (message != null && message.Success && message.Result != null) { smartContactEnterpriseListViewData.Entities = message.Result; //var t = new EnterpriseEntity[3]; //t[0] = new EnterpriseEntity {Id = 1, Name = "Test1", UuId = "AZERTY1234", IsActive = true}; //t[1] = new EnterpriseEntity {Id = 2, Name = "Test2", UuId = "WXCVBBN6548", IsActive = true}; //t[2] = new EnterpriseEntity {Id = 3, Name = "Test3", UuId = "QSDFDG542358", IsActive = false}; //smartContactEnterpriseListViewData.Entities = t; } else { if(message == null) Logger.Error("Get all enterprises fail : Message is null"); if(message != null && !message.Success) Logger.Error("Get all enterprises fail : Message success is false"); if(message != null && message.Success && message.Result == null) Logger.Error("Get all enterprises fail : Message result is null"); } return PartialView(smartContactEnterpriseListViewData); }
This method have to get all enterprises and return it to View. All of this works without problem on my local IIS. But as soon as I build it on a distant server, I can not display this view anymore, and no error are displayed.
I log the List() method by specifying "List method enterred", but on the distant server its is never called. I have also mocked the call to WCF to confirm that the problent doesn't come from here (as you can see commented code in the List method)
If one of you have any idea, that would be apreciated :)
Finally I've solved the problem. The problem wasn't the Role Authorization. Actually, my WCF returned me to much data, so it triggered a maxBufferedSizeOverflow. In fact, I have less data on my local server than on the distant one. So I implemented a method to return less data, by establishing pagination. Problem solved !