开发者

why I am getting HTTP/1.1 500 Internal Server Error?

In have a controller class that handle a Contact object. In this controller I have defined some actions like the two I am showing here

public ActionResult Edit(int id)
{
    ContactModel cm = loadContactModel(id);
    cm.ModelState = ModelStateEnum.Edit;
    return PartialView("Contact", cm);
}

public ActionResult AddAddress(int id)
{
    AddressModel am = new AddressModel() { ModelState = ModelStateEnum.Add };
    return PartialView("Address", am);
}

The first load the Contact Detail view to edit a contact and the second load an Address detail view to add an Address to a Contact. On the UI side I have, in the same page, a button and an anchor that respectively call the same javascript function, this one

function loadDialog(action, id, title) {
    $("#contactPanel").dialog("option", "title", title);
    var urlAction = action;
    if (id != "") urlAction = urlAction + "/" + id;
    $.ajax({
        type: "get",
        dataType: "html",
        url: urlAction,
        data: {},
        success: function(response) {
            $("#contactPanel").html('').html(response).dialog('open');
        }
    });
}

This function simply load 开发者_StackOverflow中文版a jQuery dialog and set its content to what is returned back from the ajax call.

The problem is that when I call the AddAddress action I get HTTP/1.1 500 Internal Server Error.

I have used Fiddler to look at the http request and this is what I see

why I am getting HTTP/1.1 500 Internal Server Error?

Any suggestion???


Ok!!! Found the problem: there was a compile error inside the second view object. Looking at the detials of the response I have got to the problem!!!

:)


Alternatively, this error can occur if the view is not found due to issues like: View not in the right folder or setting the wrong "Build Action" on the file in question (its in its property). A recommendation I have is to use Fiddler and look at the "Raw" tab for hints.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜