加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-4 – Telerik MVC索引超出范围

发布时间:2020-12-16 07:45:38 所属栏目:asp.Net 来源:网络整理
导读:我正在建立一个混合的ASP.NET MVC / ASP.NET站点(基于Kentico,如果这很重要)并且遇到问题: [ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index] System.ThrowHe
我正在建立一个混合的ASP.NET MVC / ASP.NET站点(基于Kentico,如果这很重要)并且遇到问题:

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.ThrowHelper.ThrowArgumentOutOfRangeException() +72
   System.Collections.ObjectModel.Collection`1.set_Item(Int32 index,T value) +10419142
   Telerik.Web.Mvc.UI.HtmlHelperExtension.Telerik(HtmlHelper`1 helper) in f:115GriffinCurrent FullSourcesSourceTelerik.Web.MvcUIHtmlHelperExtension.cs:57
   ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:tempair-vendViewsShared_Layout.cshtml:6

我发现这个document并且我相信我已经正确地完成了 – 我现在已经重做了3次,但我显然仍然缺少一些东西.

有人有主意吗?我可以发布什么来帮助解决这个问题?

以下是web.config的相关部分:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <configSections>
    <!-- Content staging BEGIN -->
    <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration,Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
    <!-- Content staging END -->
    <sectionGroup name="telerik">
      <section name="webAssets" type="Telerik.Web.Mvc.Configuration.WebAssetConfigurationSection,Telerik.Web.Mvc" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
  </appSettings>
  <telerik>
    <webAssets useTelerikContentDeliveryNetwork="true" />
  </telerik>
  <connectionStrings>
    <clear/>
  </connectionStrings>
  <system.web>
    <pages validateRequest="false" clientIDMode="AutoID">
      <controls>
        <add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
        <add tagPrefix="cms" namespace="CMS.Controls" assembly="CMS.Controls"/>
        <add tagPrefix="cms" namespace="CMS.FormEngine" assembly="CMS.FormEngine"/>
        <add tagPrefix="cms" namespace="CMS.FormControls" assembly="CMS.FormControls"/>
        <add tagPrefix="cms" namespace="CMS.ExtendedControls" assembly="CMS.ExtendedControls"/>
        <add tagPrefix="cms" namespace="CMS.PortalControls" assembly="CMS.PortalControls"/>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization"/>
      </controls>
      <namespaces>
        <add namespace="System.Web.Http"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="CMS.CMSHelper"/>
        <add namespace="CMS.GlobalHelper"/>
        <add namespace="Telerik.Web.Mvc.UI" />
        <add namespace="Telerik.Reporting" />
        <add namespace="Telerik.ReportViewer.WebForms" />
      </namespaces>
    </pages>
    <customErrors defaultRedirect="~/CMSMessages/error.aspx" mode="Off">
      <error statusCode="404" redirect="~/CMSMessages/PageNotFound.aspx"/>
    </customErrors>
    <authentication mode="Forms">
      <forms loginUrl="CMSPages/logon.aspx" defaultUrl="Default.aspx" name=".ASPXFORMSAUTH" timeout="60000" slidingExpiration="true"/>
    </authentication>
    <httpRuntime maxRequestLength="2097151" waitChangeNotification="1" maxWaitChangeNotification="3600" requestValidationMode="2.0" maxUrlLength="1000"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US"/>
    <membership defaultProvider="CMSProvider" userIsOnlineTimeWindow="30">
      <providers>
        <clear/>
        <add name="CMSProvider" type="CMS.MembershipProvider.CMSMembershipProvider" connectionStringName="CMSConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed"/>
      </providers>
    </membership>
    <roleManager defaultProvider="CMSRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
      <providers>
        <clear/>
        <add name="CMSRoleProvider" type="CMS.MembershipProvider.CMSRoleProvider" connectionStringName="CMSConnectionString" applicationName="SampleApplication" writeExceptionsToEventLog="false"/>
      </providers>
    </roleManager>
    <httpHandlers>
      <add path="ChartImg.axd" verb="*" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,System.Web.DataVisualization,Version=4.0.0.0,PublicKeyToken=31bf3856ad364e35" validate="false"/>
      <add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler,Telerik.Web.Mvc" />
      <add type="Telerik.ReportViewer.WebForms.HttpHandler,Telerik.ReportViewer.WebForms,Version=6.1.12.611,PublicKeyToken=a9d7983dfcc261be" path="Telerik.ReportViewer.axd" verb="*" validate="true" />
    </httpHandlers>
    <httpModules>
      <add name="XHtmlModule" type="CMS.CMSOutputFilter.OutputFilterModule,CMS.OutputFilter"/>
      <add name="CMSApplicationModule" type="CMS.CMSHelper.CMSApplicationModule,CMS.CMSHelper"/>
    </httpModules>
    <xhtmlConformance mode="Strict"/>
    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>
    <compilation debug="true" numRecompilesBeforeAppRestart="100" targetFramework="4.0">
      <assemblies>
        <add assembly="SMDiagnostics,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="Microsoft.Transactions.Bridge,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Management,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Windows.Forms,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Design,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Security,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Configuration.Install,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.DirectoryServices,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Configuration,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Data,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Xml,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Drawing,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions,PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Extensions.Design,PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Deployment,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Transactions,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.RegularExpressions,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Data.Linq,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Messaging,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.IdentityModel.Selectors,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.ServiceProcess,PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.DataVisualization,PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Data.Entity,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Entity.Design,PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Abstractions,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers,Version=1.0.0.0,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Http,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages,Version=2.0.0.0,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages.Razor,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="Telerik.Web.Mvc" />
      </assemblies>
      <!-- Different programming languages BEGIN -->
      <!--
      <codeSubDirectories>
        <add directoryName="CSCode"></add>
        <add directoryName="VBCode"></add>
      </codeSubDirectories>
      -->
      <!-- Different programming languages END -->
    </compilation>
    <httpCookies httpOnlyCookies="true"/>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <!-- Windows authentication BEGIN -->
  <!--
  <location path="">
    <system.web>
        <authorization>
          <deny users="?"/>
        </authorization>
    </system.web>
  </location>
  -->
  <!-- Windows authentication END -->
  <location path="cms">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
  <!-- WebDAV location BEGIN -->
  <location path="cms/files">
    <system.web>
      <httpHandlers>
        <clear/>
        <add verb="*" path="*" type="CMS.WebDAV.WebDAVHandler,CMS.WebDAV"/>
      </httpHandlers>
      <httpRuntime executionTimeout="2400" maxRequestLength="2097151"/>
    </system.web>
    <system.webServer>
      <handlers>
        <clear/>
        <add name="CMSWebDAVHandler" path="*" verb="*" type="CMS.WebDAV.WebDAVHandler,CMS.WebDAV"/>
        <remove name="xoml-Integrated"/>
        <add name="*.vbhtml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.vbhtml" type="System.Web.HttpForbiddenHandler"/>
        <add name="*.vbhtm_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.vbhtm" type="System.Web.HttpForbiddenHandler"/>
        <add name="*.cshtml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.cshtml" type="System.Web.HttpForbiddenHandler"/>
        <add name="*.cshtm_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.cshtm" type="System.Web.HttpForbiddenHandler"/>
        <add name="*.xamlx_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.xamlx" type="System.Xaml.Hosting.XamlHttpHandlerFactory,System.Xaml.Hosting,PublicKeyToken=31bf3856ad364e35"/>
        <add name="*.xoml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.xoml" type="System.ServiceModel.Activation.HttpHandler,System.ServiceModel.Activation,PublicKeyToken=31bf3856ad364e35"/>
        <add name="*.svc_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.svc" type="System.ServiceModel.Activation.HttpHandler,PublicKeyToken=31bf3856ad364e35"/>
        <add name="*.soap_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory,System.Runtime.Remoting,PublicKeyToken=b77a5c561934e089"/>
        <add name="*.rem_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.rem" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory,PublicKeyToken=b77a5c561934e089"/>
        <add name="*.asmx_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptResource.axd" preCondition="integratedMode,runtimeVersionv2.0" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler,PublicKeyToken=31bf3856ad364e35"/>
        <add name="*_AppService.axd_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory,PublicKeyToken=31bf3856ad364e35"/>
        <add name="eurl.axd_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="eurl.axd" type="System.Web.HttpNotFoundHandler"/>
      </handlers>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="2147483648"/>
        </requestFiltering>
      </security>
      <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
  </location>
  <!-- WebDAV location END -->
  <!-- Content staging BEGIN -->
  <microsoft.web.services3>
    <security>
      <securityTokenManager>
        <add type="CMS.Synchronization.WebServiceAuthorization" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken"/>
      </securityTokenManager>
      <x509 allowTestRoot="true" verifyTrust="true"/>
    </security>
    <policy fileName="wse3policy.config"/>
    <diagnostics>
      <trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo"/>
    </diagnostics>
  </microsoft.web.services3>
  <!-- Content staging END -->
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" >
      <remove name="WebDAVModule"/>
      <remove name="XHtmlModule"/>
      <remove name="CMSApplicationModule"/>
      <remove name="UrlRoutingModule"/>
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=3.5.0.0,PublicKeyToken=31BF3856AD364E35"/>
      <add name="XHtmlModule" type="CMS.CMSOutputFilter.OutputFilterModule,CMS.OutputFilter"/>
      <add name="CMSApplicationModule" preCondition="managedHandler" type="CMS.CMSHelper.CMSApplicationModule,CMS.CMSHelper"/>
      <add name="ErrorHandlerModule" preCondition="managedHandler" type="System.Web.Mobile.ErrorHandlerModule,System.Web.Mobile,PublicKeyToken=b03f5f7f11d50a3a"/>
    </modules>
    <handlers>
      <remove name="asset" />
      <add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler,Telerik.Web.Mvc" />
      <add name="Telerik.ReportViewer.axd_*" type="Telerik.ReportViewer.WebForms.HttpHandler,PublicKeyToken=a9d7983dfcc261be" path="Telerik.ReportViewer.axd" verb="*" preCondition="integratedMode" />
      <remove name="MetaWeblogAPI"/>
      <remove name="UrlRoutingHandler"/>
      <add name="MetaWeblogAPI" preCondition="integratedMode" verb="*" path="MetaWeblog.ashx" type="CMS.MetaWeblogProvider.MetaWeblogAPI,CMS.MetaWeblogProvider"/>
      <add name="ChartImageHandler" preCondition="integratedMode" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,PublicKeyToken=31bf3856ad364e35"/>
      <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler,System.Web,PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
    <validation validateIntegratedModeConfiguration="false"/>
    <httpErrors>
      <remove statusCode="405" subStatusCode="-1"/>
      <remove statusCode="404" subStatusCode="-1"/>
      <error statusCode="404" prefixLanguageFilePath="" path="/CMSPages/handler404.aspx" responseMode="ExecuteURL"/>
      <error statusCode="405" prefixLanguageFilePath="" path="/CMSPages/handler404.aspx" responseMode="ExecuteURL"/>
    </httpErrors>
    <rewrite>
      <rules>
        <rule name="www" enabled="false" stopProcessing="true">
          <match url="(.*)"/>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www.([.x20-x7E]+)$" negate="true"/>
            <add input="{HTTP_HOST}" pattern="http://ht.io-web.com" negate="true"/>
          </conditions>
          <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

解决方法

这很奇怪.您是否尝试从 here获取示例项目并查看您的项目是否存在任何显着差异?与工作项目相比可能有助于您跟踪问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读