ASP.net内部服务器错误500.19

时间:2018-05-07 21:01:41

标签: asp.net asp.net-mvc

这是ASP.NET mvc项目。我试图用ajax获取4个表数据。首先,我创建新类然后使用jsonresult,然后在视图中我使用了ajax。

[HttpPost]
    public JsonResult GetallData(int id)
    {
        MultipleViewModel model = new MultipleViewModel();
        List<InformationSecurityData> iso = db.InformationSecurityDatas.Where(x => x.Supplier_ID == id).ToList();
        List<SurveyForm> tender = db.SurveyForms.Where(x => x.Supplier_ID == id ).ToList();
        List<ProcurementData> procurement = db.ProcurementDatas.Where(x => x.Supplier_ID == id ).ToList();
        List<Supplier> supp = db.Suppliers.Where(x => x.Supplier_ID == id ).ToList();

        model.Inf_Sec_Dat = iso;
        model.Proc_Dat = procurement;
        model.Tender_Dat = tender;
        model.Supp_dat = supp;
        string json = JsonConvert.SerializeObject(model, 
        Formatting.Indented,
        new JsonSerializerSettings
        {
            ReferenceLoopHandling = ReferenceLoopHandling.Serialize
        });

        return Json(model, JsonRequestBehavior.AllowGet);
    }

控制器中的功能

      <script type="text/javascript">
        iso_data = [];
        tender_data = [];


        $(document).ready(function () {
            $("#GetallData").click(function () {
                var id = $("#id").val();
                $.ajax({
                    url: '/Dashboard/GetallData/' + id,
                    type: 'POST',
                    dataType: 'json',
                    success: function (data) {
                        alert("success ");

视野中的ajax

public class MultipleViewModel
{
    public List<InformationSecurityData> Inf_Sec_Dat { get; set; }
    public List<ProcurementData> Proc_Dat { get; set; }
    public List<SurveyForm> Tender_Dat { get; set; }
    public List<Supplier> Supp_dat { get; set; }

}

viewmodel class

<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please 
visit
  https://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit 
http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" 
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, 
EntityFramework, Version=6.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <!--
    For a description of web.config changes see 
http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5.2" />
      </system.Web>
  -->
   <system.web>
    <authentication mode="Forms">
      <forms cookieless="UseCookies" loginUrl="~/user/login" 
slidingExpiration="true" />
    </authentication>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" 
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, 
Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" 
publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" 
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" 
publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" 
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" 
/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" 
newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" 
publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" 
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" 
publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" 
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" 
publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" 
/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" 
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, 
 Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
  </system.webServer>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
  /system.codedom>
  <entityFramework>
   <defaultConnectionFactory 
type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, 
EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" 
type="System.Data.Entity.SqlServer.SqlProviderServices, 
EntityFramework.SqlServer" />
    </providers>
   </entityFramework>
  <connectionStrings>
        <add name="SupplierEvaluationEntities1" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string='data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=&quot;C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\SupplierEvaluation.mdf&quot;;integrated security=True;multipleactiveresultsets=True;connect timeout=30;application name=EntityFramework'" providerName="System.Data.EntityClient" />
     </connectionStrings>
</configuration>

的web.config

我无法获取数据?我尝试了一些解决方案,但问题没有解决。究竟我需要纠正什么?你能告诉我到底我的错误是什么,还是与代码的这些部分有关?我得到了这个

 System.StackOverflowException
 HResult=0x800703E9
 Message=Exception of type 'System.StackOverflowException' was thrown.

1 个答案:

答案 0 :(得分:0)

在你的JSON函数上放一个断点,你得到id吗?我认为您的网址错误,应该是:

  URL: "/Dashboard/GetallData/",
  data: { id: id },
  cache: false,
  type: "POST",
  success: function (data) {
      alert("success ");
  },
  error: function (reponse) {
      alert("error : " + reponse);
  }