2

My code works perfectly in VS2010 C# but once published to IIS7 the PartialView (list of records) does not get rendered in the View...it rolls to a new page without the data except for the correct record count retrieved from SQL server. SQL server is on separate box.

I have searched for hours on this site with no luck finding a resolution.

View with the RenderPartial:

   <table style="width:100%">
<tr>
<td>
<h3>Outage Tracking List (Open or Active)</h3>
</td>
<td style="text-align:right">
<h1><%: ViewData["ApplicationName"]%></h1>
</td>
</tr>
</table>    

<% Html.RenderPartial("OutageSearch",this.ViewData.Model); %>

PartialView:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&ltOutageTrackingWebSite.Models.OutageViewModel" %>
<div>

<script language="javascript" type="text/javascript">

    function OutageSearch() {

        $("#OutageSearchForm #CurrentPageNumber").val("1");       
        PostSearchForm();

    }

Various functions then the rest of the partialview

  <% using (Ajax.BeginForm("OutageSearch", null,
        new AjaxOptions { UpdateTargetId = "DivOutageSearchResults", OnComplete="OutageSearchComplete" },
            new { id = "OutageSearchForm" })) { %>

<table style="background-color: #ebeff2;  width: 100%; border:solid 1px #9fb8e9" cellspacing="2" cellpadding="2">
    <tr>
        <td style="width: 60%; text-align: left">
            <input id="btnSearch" onclick="OutageSearch();" type="submit" value="List Open/Active" />
        </td>
    </tr>
</table>

<div id="DivOutageSearchResults">    
 <% Html.RenderPartial("OutageSearchResults", this.ViewData.Model); %> 
</div>

<% } %>

additional PartialView

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<%OutageTrackingWebSite.Models.OutageViewModel" >
    <input name="CurrentPageNumber" type="hidden" id="CurrentPageNumber" value="<%=Model.CurrentPageNumber%>" />
<input name="TotalPages" type="hidden" id="TotalPages" value="<%=Model.TotalPages%>" />     
<input name="SortBy" type="hidden" id="SortBy" value="<%=Model.SortBy%>" />     
<input name="SortAscendingDescending" type="hidden" id="SortAscendingDescending" value="<%=Model.SortAscendingDescending%>" />     

<input name="PageSize" type="hidden" id="PageSize" value="9" />

 <script language="javascript" type="text/javascript">
function GetOutageDetails(OutageID) {

             if (formIsDisabled == false) {

                 DisableForm();

                 formData = "OutageID=" + OutageID;

                 setTimeout(PostOutageIDToServer, 1000);

             }

         }

         function PostOutageIDToServer() {

             $.post("/Outage/GetOutageInformation", formData, function (data, textStatus) {
                 OutageUpdateComplete(data);
             }, "json");

         }
         

Controller


       public ActionResult DisplayOutageList()
        {


            Models.OutageViewModel outageViewModel = new Models.OutageViewModel();

            outageViewModel.TotalPages = 0;
            outageViewModel.TotalRows = 0;
            outageViewModel.CurrentPageNumber = 0;

            ViewData.Model = outageViewModel;

            string applicationName = Convert.ToString( System.Configuration.ConfigurationManager.AppSettings["ApplicationName"]);

            ViewData["ApplicationName"] = applicationName;

            return View("OutageMaintenance");
        }

        /// 
        /// Outage Search
        /// 
        /// 
        public PartialViewResult OutageSearch()
        {
            long totalRows;
            long totalPages;
            bool returnStatus;
            string returnErrorMessage;

            OutageBLL OutageBLL = new OutageBLL();

            Models.OutageViewModel outageViewModel = new Models.OutageViewModel();

            this.UpdateModel(outageViewModel);

            List Outages = OutageBLL.OutageSearch(
                outageViewModel,
                outageViewModel.CurrentPageNumber,
                outageViewModel.PageSize,
                outageViewModel.SortBy,
                outageViewModel.SortAscendingDescending, 
                out totalRows,
                out totalPages,
                out returnStatus,
                out returnErrorMessage);

            ViewData["Outages"] = Outages;

            outageViewModel.TotalPages = totalPages;
            outageViewModel.TotalRows = totalRows;

            ViewData.Model = outageViewModel;

            return PartialView("OutageSearchResults");

        }


         /// 
        /// Get Outage Information
        /// 
        /// 
        public JsonResult GetOutageInformation()
        {

            bool returnStatus;
            string returnErrorMessage;
            List returnMessage;

            OutageBLL outageBLL = new OutageBLL();

            Models.OutageViewModel outageViewModel = new Models.OutageViewModel();

            this.TryUpdateModel(outageViewModel);

            Outage outage = outageBLL.GetOutageInformation(
                outageViewModel.OutageID, 
                out returnStatus, 
                out returnErrorMessage,
                out returnMessage);

            outageViewModel.UpdateViewModel(outage, typeof(Outage).GetProperties());

            outageViewModel.ReturnMessage = returnMessage;
            outageViewModel.ReturnStatus = returnStatus;
            outageViewModel.OutageScheduledDate = UtilitiesBLL.FormatDate(outageViewModel.ScheduledDate);
            outageViewModel.OutagePlannedDuration = UtilitiesBLL.FormatDuration(outageViewModel.PlannedDuration);

            return Json(outageViewModel);

        }
treeSeeker
  • 97
  • 1
  • 2
  • 11
  • Sure...I did not post code in my original question because I am not sure where the problem is. What would be the most helpful...View, partialview or the controller? – treeSeeker May 08 '11 at 19:29
  • Maybe to code that renders the PartialView and the Controller action – Lee Gunn May 08 '11 at 19:39
  • Are you sure you are using exactly the same assemblies in both cassini and IIS? Both from your project and MVC. – David May 08 '11 at 20:15
  • I'm not sure what you mean by cassini? – treeSeeker May 08 '11 at 20:27
  • Just found - default Visual Studio Development Server (aka Cassini). http://stackoverflow.com/questions/2469555/any-tutorials-about-how-to-create-an-asp-net-mvc-2-website-and-run-it-against-loc – treeSeeker May 08 '11 at 20:54
  • Not sure about the *assemblies* question. I have published the project to the IIS 7 server and the MVC dll is in my /bin folder. What else do I need to look for? – treeSeeker May 08 '11 at 21:19

1 Answers1

0

Check your included JavaScript files on the deployed version. If you are missing some files (MicrosoftMvcAjax.js, jQuery.js), the page could simply be posting instead of using an Ajax post.

Henry Fieger
  • 346
  • 3
  • 5