.Net Core 2.2 visual studio crashes when ajax is called

1

I have an AJAX function

$.ajax({
    type: "POST",
    url: "Action",
    data: JSON.stringify(model),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: successFunc,
    error: errorFunc
});

then I have a controller with the action i want to call

    [HttpPost]
    public async Task<IActionResult> Action([FromBody] Model model)
    {
        var result = await service.DoSomething(model)
        var callbackUrl = "CallbackUrl";

        return Json(callbackUrl);
    }

success function of AJAX call

            function successFunc(callbackUrl) {
                window.location(callbackUrl);
            };

My problem is that when ajax post is invoked the application crashes with "The program '[17188] dotnet.exe' has exited with code -1 (0xffffffff)."

Interestingly the service's "DoSomething" method actually adds stuffs into database and callbackUrl is returned - all correctly

Putting breakpoint on service's line with "DoSomething" method in the Action doesn't work - application crashes before it can hit the breakpoint - the code is executed tho.

Any idea how could I find out what's wrong with this?

EDIT: the only thing that crashes is visual studio, IIS is still running

EDIT2: tried to recreate the problem with brand new .net core web application

step 1) create .net web application with individual user login

step 2) create ViewModel with string property "MyProperty" just to see passing parameters is ok

public class ViewModel
{
    public string MyProperty { get; set; }
}

step 3) add new action to your controller

    public IActionResult SomeAction([FromBody] ViewModel model)
    {
        var callbackUrl = "callbackUrl";

        return Json(callbackUrl);
    }

step 4) add this to index.cshtml at the end of the file

<script type="text/javascript" src="~/lib/jquery/dist/jquery.js"></script>

<script>
    $(document).ready(function () {
        var model = {
            MyProperty: "my random property"
        };

        $.ajax({
            type: "POST",
            url: "Home/SomeAction",
            data: JSON.stringify(model),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processData: false,
            success: successFunc,
            error: errorFunc
        });

        function successFunc(result) {
            alert("success " + result);
        };

        function errorFunc(result) {
            alert("error " + result);
        };
    });
</script>

and it's working - have no idea why is VS crashing with mine example above it should be on the same principle

c#
.net
ajax
.net-core
asked on Stack Overflow Jan 4, 2019 by boni • edited Jan 5, 2019 by boni

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0