davomcdavo
davomcdavo

Reputation: 619

asp.net core web api post fields always null

for years I've used previous versions of asp.net (MVC and WebForms) and now after a 2 year break of not using asp.net I decided to try out the new version on top of AWS Lambda using this library and it's literally been hours and I still can't get it to ajax-post an object! I'm on Ubuntu running VS Code.

As the title says I either get a null object or if the object manages to have any properties their values are always null. If someone could help I would very much appreciate it. Here's a snippet of the front-end code:

$(document).ready(function () {

$('form').submit(function(event) {
    event.preventDefault();
    // var data = $('form').serialize();
    var data = {
        Name: $("input[name='name']",this).val(),
        Email: $("input[name='email']",this).val(),
        FindUs: $("input[name='find-us']",this).val(),
        Newsletter: $("input[name='newsletter']",this).val(),
        Message: $("textarea[name='message']",this).val()//,
        //TODO:
        //GRecaptchaResponse: $("input[name='g-recaptcha-response']",this).val()
    };

    alert(JSON.stringify(data));
    console.log(JSON.stringify(data));

    $.ajax({
        type: 'POST',
        url: '/api/contacts',
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(data),
        success: function(response) {
            alert(response);
            console.log('Data received: ');
            console.log(response);
        },
        failure: function(response) {
            //...
        },
        error: function(response) {
            //...
        }
    });
});

}

Here's the controller code (I'm omitting the namespace) (here's where most of my "grievances" have been documented...):

[Route("api/[controller]")]
public class ContactsController : Controller
{
    // POST api/values
    [HttpPost]
    public JsonResult Post([FromBody]Contact contact)
    {
        //also tried:
        //public JsonResult Post([FromBody]Object contact)
        //public JsonResult Post([FromForm]Contact contact)
        //public JsonResult Post([FromForm]Object contact)
        //public JsonResult Post(Contact contact)
        //public JsonResult Post(Object contact)
        //public JsonResult Post(string Name, string Email, ...)
        // but always get null properties or a "System.Object" with no fields


        try
        {
            var myContact = JsonConvert.DeserializeObject<dynamic>(contact.ToString());
        }
        catch (Exception e)
        {
            //always crashes
        }

        Type myType = contact.GetType();
        IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());

        foreach (PropertyInfo prop in props)
        {
            //doesn't even go into this foreach loop
            //and when it does the values are always null

            object propValue = prop.GetValue(contact, null);
        }

        string stringContact = contact.ToString();

        try 
        {
            Contact anotherContact = JsonConvert.DeserializeObject<Contact>(stringContact);
        }
        catch (Exception e)
        {
            //get “Unexpected character encountered while parsing value: S. Path '', line 0, position 0”
        }

        var statusReturn = new Dictionary<string, string>();
        statusReturn.Add("status", "success");
        return Json(statusReturn);// on a good note, the front end picks this up and says all good...
    }
}

Here's the model:

public class Contact
{
    [Required]
    [MaxLength(40)]
    public string Name { get; set; }

    [Required]
    [MaxLength(40)]
    public string Email { get; set; }

    [Required]
    [MaxLength(40)]
    public string FindUs { get; set; }

    [Required]
    public bool Newsletter { get; set; }

    [MaxLength(250)]
    public string Message { get; set; }

    // [MaxLength(500)]
    // public string GRecaptchaResponse { get; set; }
}

And finally here's Startup.cs

public class Startup
{
    public const string AppS3BucketKey = "AppS3Bucket";

    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

        builder.AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public static IConfigurationRoot Configuration { get; private set; }

    // This method gets called by the runtime. Use this method to add services to the container
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        // Pull in any SDK configuration from Configuration object
        services.AddDefaultAWSOptions(Configuration.GetAWSOptions());

        // Add S3 to the ASP.NET Core dependency injection framework.
        services.AddAWSService<Amazon.S3.IAmazonS3>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        //serve index.html by default (and ONLY serve index.html)
        DefaultFilesOptions options = new DefaultFilesOptions();
        options.DefaultFileNames.Clear();
        options.DefaultFileNames.Add("index.html");
        app.UseDefaultFiles(options);

        loggerFactory.AddLambdaLogger(Configuration.GetLambdaLoggerOptions());
        app.UseMvc();

        //enable wwwroot
        app.UseStaticFiles();
    }
}

thanks

UPDATE

There are a ton of warnings when I run the website as you can see below (I am running "dotnet restore"):

    --------------------------------------------------------------------------------

You may only use the Microsoft .NET Core Debugger (clrdbg) with Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you develop and test your applications.


Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Private.CoreLib.ni.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/Repos/website_Some.software/backend/SomeSoftwareWebAPI/src/SomeSoftwareWebAPI/bin/Debug/netcoreapp1.0/SomeSoftwareWebAPI.dll'. Symbols loaded. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Runtime.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/mscorlib.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Hosting/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Hosting.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Hosting.Abstractions/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Hosting.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Logging.Abstractions/1.0.1/lib/netstandard1.1/Microsoft.Extensions.Logging.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.DependencyInjection.Abstractions/1.0.1/lib/netstandard1.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Server.Kestrel/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Server.Kestrel.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.IO.FileSystem.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Server.IISIntegration/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Server.IISIntegration.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.FileProviders.Abstractions/1.0.1/lib/netstandard1.0/Microsoft.Extensions.FileProviders.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Collections.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Configuration/1.0.0/lib/netstandard1.1/Microsoft.Extensions.Configuration.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Configuration.Abstractions/1.0.1/lib/netstandard1.0/Microsoft.Extensions.Configuration.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Configuration.EnvironmentVariables/1.0.0/lib/netstandard1.3/Microsoft.Extensions.Configuration.EnvironmentVariables.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Runtime.Extensions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Primitives/1.0.1/lib/netstandard1.0/Microsoft.Extensions.Primitives.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Threading.Tasks.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Linq.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.IO.FileSystem.Primitives.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Runtime.InteropServices.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.DependencyInjection/1.0.0/lib/netstandard1.1/Microsoft.Extensions.DependencyInjection.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.ComponentModel.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Http.Features/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Http.Features.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Console.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Http.Abstractions/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Http.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.PlatformAbstractions/1.0.0/lib/netstandard1.3/Microsoft.Extensions.PlatformAbstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Logging/1.0.0/lib/netstandard1.1/Microsoft.Extensions.Logging.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Http/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Http.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Options/1.0.1/lib/netstandard1.0/Microsoft.Extensions.Options.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Diagnostics.DiagnosticSource.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.ObjectPool/1.0.0/lib/netstandard1.3/Microsoft.Extensions.ObjectPool.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.AppContext.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.TypeExtensions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.FileProviders.Physical/1.0.0/lib/netstandard1.3/Microsoft.Extensions.FileProviders.Physical.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.IO.FileSystem.Watcher.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Collections.Concurrent.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Threading.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Diagnostics.Tracing.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Hosting.Server.Abstractions/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.IO.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Linq.Expressions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Globalization.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Configuration.FileExtensions/1.0.0/lib/netstandard1.3/Microsoft.Extensions.Configuration.FileExtensions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Configuration.Json/1.0.0/lib/netstandard1.3/Microsoft.Extensions.Configuration.Json.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.Emit.ILGeneration.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Runtime.Handles.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.Primitives.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.Emit.Lightweight.dll'. Cannot find or open the symbol file. Loaded 'Anonymously Hosted DynamicMethods Assembly'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Newtonsoft.Json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Dynamic.Runtime.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.ObjectModel.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Private.Uri.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Core/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.Core.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/AWSSDK.Extensions.NETCore.Setup/3.3.0.2/lib/netstandard1.3/AWSSDK.Extensions.NETCore.Setup.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/AWSSDK.Core/3.3.7/lib/netstandard1.3/AWSSDK.Core.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/AWSSDK.S3/3.3.5.2/lib/netstandard1.3/AWSSDK.S3.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.ApiExplorer/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.ApiExplorer.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.ViewFeatures/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.ViewFeatures.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Razor/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.Razor.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Razor.Runtime/1.0.0/lib/netstandard1.5/Microsoft.AspNetCore.Razor.Runtime.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.TagHelpers/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.TagHelpers.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.DataAnnotations/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.DataAnnotations.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Formatters.Json/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.Formatters.Json.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Cors/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.Cors.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Abstractions/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Mvc.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Routing/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Routing.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.DependencyModel/1.0.0/lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.DotNet.InternalAbstractions/1.0.0/lib/netstandard1.3/Microsoft.DotNet.InternalAbstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.Text.Encodings.Web/4.0.0/lib/netstandard1.0/System.Text.Encodings.Web.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Buffers.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Routing.Abstractions/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Routing.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Diagnostics.Debug.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Authorization/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Authorization.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.DataProtection/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.DataProtection.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Antiforgery/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.Antiforgery.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.WebEncoders/1.0.1/lib/netstandard1.0/Microsoft.Extensions.WebEncoders.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Text.Encoding.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Cryptography.Internal/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Cryptography.Internal.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.DataProtection.Abstractions/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.DataProtection.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/Microsoft.CodeAnalysis.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Mvc.Razor.Host/1.0.1/lib/netstandard1.6/Microsoft.AspNetCore.Mvc.Razor.Host.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Razor/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Razor.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Caching.Abstractions/1.0.0/lib/netstandard1.0/Microsoft.Extensions.Caching.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Caching.Memory/1.0.0/lib/netstandard1.3/Microsoft.Extensions.Caching.Memory.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.Cors/1.0.0/lib/netstandard1.3/Microsoft.AspNetCore.Cors.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.AspNetCore.StaticFiles/1.0.1/lib/netstandard1.3/Microsoft.AspNetCore.StaticFiles.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Amazon.Lambda.Logging.AspNetCore/1.0.0/lib/netstandard1.3/Amazon.Lambda.Logging.AspNetCore.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Extensions.Localization.Abstractions/1.0.0/lib/netstandard1.0/Microsoft.Extensions.Localization.Abstractions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.Runtime.Serialization.Primitives/4.1.1/lib/netstandard1.3/System.Runtime.Serialization.Primitives.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Microsoft.Net.Http.Headers/1.0.1/lib/netstandard1.1/Microsoft.Net.Http.Headers.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Text.Encoding.Extensions.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Reflection.Extensions.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.ComponentModel.TypeConverter/4.1.0/lib/netstandard1.5/System.ComponentModel.TypeConverter.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.Collections.NonGeneric/4.0.1/lib/netstandard1.3/System.Collections.NonGeneric.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.Collections.Specialized/4.0.1/lib/netstandard1.3/System.Collections.Specialized.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/System.ComponentModel.Primitives/4.1.0/lib/netstandard1.0/System.ComponentModel.Primitives.dll'. Cannot find or open the symbol file. Loaded '/home/someuser/.nuget/packages/Amazon.Lambda.Core/1.0.0/lib/netstandard1.3/Amazon.Lambda.Core.dll'. Cannot find or open the symbol file. [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting starting Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Net.Primitives.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Numerics.Vectors.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Threading.Timer.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Threading.ThreadPool.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Runtime.InteropServices.RuntimeInformation.dll'. Cannot find or open the symbol file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.3/System.Threading.Thread.dll'. Cannot find or open the symbol file. [Debug] Microsoft.AspNetCore.Hosting.Internal.WebHost: Hosting started Hosting environment: Development Content root path: /home/someuser/Repos/website_Some.software/backend/SomeSoftwareWebAPI/src/SomeSoftwareWebAPI Launching browser (xdg-open http://localhost:5000) Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.

And finally

I did have to downgrade a library to match aws's version, but I can't remember specifically which library it was, but after that all my unit tests passed.

I When I run "nuget restore" I get "This folder contains no solution files, nor packages.config files". And yes that's right, packages.config doesn't exist anywhere in the folders I've checked. I'm I supposed to not use the nuget command and let dotnet restore deal with it?

I've been reluctant to do this on Windows because this shouldn't require you to install Windows somewhere and then install Visual Studio with all the required extensions and updates in order to get a working project... if that's the case then there's no point in making asp.net core cross platform in the first place... Maybe I won't have any of these problems next time I try asp.net core + lambda for a future project... whenever that might be

Upvotes: 0

Views: 1237

Answers (4)

SouthShoreAK
SouthShoreAK

Reputation: 4296

I was having the same problem. I am not sure exactly what resolved it, but I did find one difference. I installed "Microsoft.AspNetCore.Diagnostics" v 1.0.3 via NuGet while trying to find the source of the issue. This caused many of the other .Net Core packages to update from 1.0.0 to 1.0.3. Now it works. Perhaps there was a bug?

Upvotes: 0

Norm Johanson
Norm Johanson

Reputation: 3177

I was able deploy this to Lambda with the Contact object filled in. The only change I made was in your Javascript change the url the ajax call goes to include the API Gateway stage name "/Prod/api/contacts".

Is there anything interesting in the CloudWatch Logs for the Lambda function? I was getting null for a while because the JSON I was sending in the Ajax was causing a ModelState error because the values didn't match the DataAnnotations in the Contact object.

Upvotes: 0

davomcdavo
davomcdavo

Reputation: 619

I will wait and try again in the future once all the relevant libraries are out of beta/rc.

Upvotes: 0

J. Doe
J. Doe

Reputation: 2747

I created own project based on code in thread and find solution. Remove contentType: "application/json; charset=utf-8", from $.ajax. After this it worked to me

Upvotes: 0

Related Questions