Srinivas Ch
Srinivas Ch

Reputation: 1256

Getting Max URL length exceeded c# MVC

  function GetUserEditProfileDetails() {
    var res = {};

    res.ID = parseInt($("#User_ID_EditProfile").val());
    res.FirstName = $("#FirstName").val();
    res.LastName = $("#LastName").val();

    res.EmailId = $("#EmailId").val();
    res.Mobile = $("#Mobile").val();
    res.ProfilePic = $(".ProfilePic").attr("src");

    return res;
}

 $.ajax({
        url: "Profile/UpdateUser",             
        async: false,
        type: "POST",
        data: GetUserEditProfileDetails(),
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        error: function (jqXHR, textStatus, errorThrown) {
            alert(JSON.stringify(jqXHR) + "-" + textStatus + "-" + errorThrown);
        }
    })

By using above code, I am trying to save the details of a user. But when the profile pic is too long then the controller method is not calling and it shows internal server error.

Upvotes: 1

Views: 608

Answers (1)

Laxman Gite
Laxman Gite

Reputation: 2318

Hi Please check below solution :

You need to change maxAllowedContentLength in Web.Config File :

In system.web :

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

And in system.webServer

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
</security>

Cheers !!

Upvotes: 1

Related Questions