PlatformNotSupportedException in IIS 7 calling jQuery Searchbox Autocomplete

Topics: ASP.NET MVC
Feb 23, 2014 at 11:26 PM
Edited Feb 24, 2014 at 2:46 AM
I am working on a MVC 4 app running under .NET 4.5 and am using the jQuery Autocomplete SearchBox. In IIS 7.5, it works just fine, but under IIS 7, I get: System.PlatformNotSupportedException: This operation requires IIS version 7.5 or higher running in integrated pipeline mode.

Can anyone help me figure out what I need to do to the code to make it work in IIS 7?

[PlatformNotSupportedException: This operation requires IIS version 7.5 or higher running in integrated pipeline mode.]
System.Web.HttpResponse.get_ClientDisconnectedToken() +3125014
System.Web.HttpResponseWrapper.get_ClientDisconnectedToken() +9
System.Web.Http.WebHost.HttpResponseBaseExtensions.GetClientDisconnectedTokenWhenFixed(HttpResponseBase response) +37
System.Web.Http.WebHost.<ProcessRequestAsyncCore>d__0.MoveNext() +136
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +60
System.Web.HttpTaskAsyncHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +6
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

JavaScript:
function registerSearch(entityName, disableSearchOnFocus, disableRedirectOnSelect, selectFunction) {
    var $searchBox = $('#' + entityName + 'Search');
    if ($searchBox) {
        var searchCache = {};
        
        $searchBox.autocomplete({
            minLength: 1,
            delay: 5,
            source: function (request, response) {
                var term = request.term;
                if (term in searchCache) {
                    response(searchCache[term]);
                    return;
                }
                $.getJSON(window.root + 'api/lookup/' + entityName + '/', request, function (data) {
                    searchCache[term] = data;
                    response(data);
                });
            },
            select: function (event, ui) {
                if (selectFunction) {
                    selectFunction(ui.item);
                }
                if (!disableRedirectOnSelect) {
                    var loc = window.root + '' + entityName + '/edit/' + ui.item.id;
                    document.location = loc;
                }
            }
        });

        if (!disableSearchOnFocus) {
            $searchBox.focus(function() {
                $searchBox.autocomplete('search', '');
            });
        }
    }
}


// Calling JavaScript:

registerSearch('property', true);
C# controller:
// GET api/lookup/property/?term=[search term]
[ActionName("property"), AcceptVerbs("GET")]
public IEnumerable<SearchResponseModal> SuperSearchProperty(string term)
{
    var searchResponse = ConstructPropertySuperQuery(term, db.Properties)
      .Where(p => p.LastAction != LastAction.Delete)
      .OrderBy(p => p.PropertyName)
      .Select(p => new SearchResponseModal {Label = p.PropertyName, Value = p.PropertyName, Id = p.PropertyId});

    return !searchResponse.Any() ? EmptySearchResponse() : searchResponse;
}
Coordinator
Feb 24, 2014 at 5:16 PM
Are you sure you are using MVC 4? Can you show us your packages.config?

Daniel Roth
Feb 24, 2014 at 9:15 PM
Edited Feb 24, 2014 at 9:16 PM
danroth27 wrote:
Are you sure you are using MVC 4? Can you show us your packages.config?

Daniel Roth
Daniel, thanks for the response...here's the contents:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net45" />
  <package id="DataAnnotationsExtensions" version="1.1.0.0" targetFramework="net45" />
  <package id="DataAnnotationsExtensions.MVC3" version="1.1.0.0" targetFramework="net45" />
  <package id="DotNetOpenAuth.AspNet" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OAuth.Consumer" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OAuth.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OpenId.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.3.4.13329" targetFramework="net45" />
  <package id="EntityFramework" version="6.0.2" targetFramework="net45" />
  <package id="Glimpse" version="1.8.1" targetFramework="net45" />
  <package id="Glimpse.AspNet" version="1.7.0" targetFramework="net45" />
  <package id="jQuery" version="1.11.0" targetFramework="net45" />
  <package id="jQuery.UI.Combined" version="1.10.4" targetFramework="net45" />
  <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
  <package id="knockoutjs" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.Data" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.OAuth" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.WebData" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Bcl" version="1.1.6" targetFramework="net45" />
  <package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
  <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Modernizr" version="2.7.1" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
  <package id="WebActivator" version="1.2.0.0" targetFramework="net45" />
  <package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
Coordinator
Feb 24, 2014 at 10:21 PM
Looks like you have actually update to MVC 5.1 (notice the version of the Microsoft.AspNet.Mvc package). There is a known issue in MVC 5.1 when running on IIS7 that we fixed in MVC 5.1.1. You should either update to the latest packages or roll back to MVC 4.

Daniel Roth
Feb 25, 2014 at 6:09 PM
Dan,

I updated MVC to 5.1.1, but, unfortunately, am still seeing the same issue...here is the updated package.config contents:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net45" />
  <package id="DataAnnotationsExtensions" version="1.1.0.0" targetFramework="net45" />
  <package id="DataAnnotationsExtensions.MVC3" version="1.1.0.0" targetFramework="net45" />
  <package id="DotNetOpenAuth.AspNet" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OAuth.Consumer" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OAuth.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OpenId.Core" version="4.3.4.13329" targetFramework="net45" />
  <package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.3.4.13329" targetFramework="net45" />
  <package id="EntityFramework" version="6.0.2" targetFramework="net45" />
  <package id="Glimpse" version="1.8.1" targetFramework="net45" />
  <package id="Glimpse.AspNet" version="1.7.0" targetFramework="net45" />
  <package id="jQuery" version="2.1.0" targetFramework="net45" />
  <package id="jQuery.UI.Combined" version="1.10.4" targetFramework="net45" />
  <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
  <package id="knockoutjs" version="3.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="5.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.Data" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.OAuth" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages.WebData" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Bcl" version="1.1.6" targetFramework="net45" />
  <package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
  <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.1.0" targetFramework="net45" />
  <package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Modernizr" version="2.7.1" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
  <package id="WebActivator" version="1.2.0.0" targetFramework="net45" />
  <package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
Coordinator
Feb 25, 2014 at 9:03 PM
Please also update the Web API packages to the latest NuGet packages.

Daniel Roth
Marked as answer by MNX65 on 2/25/2014 at 5:46 PM
Feb 26, 2014 at 1:46 AM
Whoo hoo!!! It works!!

Thanks a ton for your help!!!