简体   繁体   English

Asp.Net html.renderaction在本地工作,但在服务器上没有错误

[英]Asp.Net html.renderaction works locally but not on server no error

I'm actually working on Asp.Net MVC project, and I have a problem to load a view from another using Html.RenderAction method. 我实际上在Asp.Net MVC项目上工作,并且在使用Html.RenderAction方法从另一个视图加载视图时遇到问题。 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 : 我有一个Index.cshtml视图,看起来像这样:

     <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 mb-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". 如您所见,我使用Html.RenderAction方法加载视图“列表”。

List.schtml, displays a table with differents enterprises. List.schtml,显示包含不同企业的表。 (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. 此方法必须获取所有企业并将其返回到View。 All of this works without problem on my local IIS. 所有这些在我的本地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. 我通过指定“ entered list method”记录了List()方法,但是在远程服务器上它从未被调用。 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) 我还模拟了对WCF的调用,以确认该能力不是来自此处的(您可以在List方法中看到注释的代码)

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. 实际上,我的WCF使我得到了很多数据,因此触发了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 ! 问题解决了 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM