Ryan
Ryan

Reputation: 5546

asp.net mvc3 disable masterpage for view

How can I disable the usual _Layout.cshtml for one view.

I try to use the content of the view aboutuser.cshtml to populate a div using ajax. Do you think this is a correct approch?

 $('#SelectUser').click(function () {

            $('#userPlace').html('<strong>Loading...</strong>');
            $.post('InfoFor?userSelect=' + ($('#usersoption:selected').val()), function (data) {
                $('#userPlace').html(data);
            });
        });

Upvotes: 2

Views: 1154

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038770

Inside this view/partial:

@{
    Layout = null;
}

or from the controller action serving it return a PartialView instead of a View:

public ActionResult Foo()
{
    return PartialView();
}

Upvotes: 4

Related Questions