0

I have an ASP.NET project with AngularJS. I am using $http.put to update a certain record in the database and I need the .then to do something later. I have an IIS server. When I test the code locally using Visual Studio it works fine. However, once I move things to the IIS I am getting a 405 status.

the call I am using is this: $http.put(req, oB).then(function(r) { DoSomething(oB.Id); })

The object oB is defined in the function calling this request.

the function it is calling in the controller is:

[HttpPut("{id}")]
public async Task<ActionResult> PutOb(int id, Object ob)
{
    if (id != ob.Id)
    {
        return BadRequest();
    }
    var oldOb= _context.Object.Where(x => x.Id == ob.Id).FirstOrDefault();
    oldOb.Name = ob.Name;
    _context.Entry(oldOb).State = EntityState.Modified;


    try
    {
        await _context.SaveChangesAsync();
    }
    catch (DbUpdateConcurrencyException)
    {
        if (!obExisit(id))
        {
            return NotFound();
        }
        else
        {
            throw;
        }
    }

    return NoContent();
}

I even tried to just call the put without the .then but I was still getting the same error.

Update: Activating the FailedRequestTracing got me this in the logs. enter image description here

2
  • You need more information to analyze your problem, try using failed request tracing to see details about 405 error, this will generate detail log file, which will help you to identify the problem.
    – samwu
    Commented Jul 5 at 3:12
  • @samwu, please see the update
    – Alaa
    Commented Jul 5 at 13:59

1 Answer 1

0

After a many attempts I was able to solve the issue by following the post here. However, I had to not include the following part:

<handlers>
    <remove name="WebDAV" />
</handlers>

When this section was added I got a 500 error.

Not the answer you're looking for? Browse other questions tagged or ask your own question.