This is a migrated thread and some comments may be shown as answers.

[Solved] Grid Ajax Binding and Authorize always return "parseerror"

1 Answer 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andri
Top achievements
Rank 1
Andri asked on 30 Jan 2012, 05:34 AM
I have grid that does ajax binding

[GridAction]
[Authorize]
public ActionResult _Select()
{
    return View(new GridModel(db.Rekanans.ToList()));
}

@{Html.Telerik().Grid<Rekanan>()
        .DataBinding(db => db.Ajax()
            .Select("_Select", "Rekanan")
         )
        .ClientEvents(e=>e.OnError("onGridError"))
        .Render();
        }
 
<script type="text/javascript">
    function onGridError(e) {
        var xhr = e.XMLHttpRequest;
        var status = e.textStatus;
        alert(status);
        alert(xhr.status);
        e.preventDefault();
    }
</script>

I have tried to access this action with an unauthenticated user, but the e.textStatus always "parseerror"  and the xhr status always undefined, not HTTP 403.

Could you please guide me to the right direction to handle this.

Using 2011.Q3.1115

1 Answer, 1 is accepted

Sort by
0
Sam Rossetti
Top achievements
Rank 1
answered on 03 May 2012, 08:35 PM
We had a similar issue in our application. When the users session time out ASP was redirecting the user to our login page. This was due to a web.config setting in the app.

<authentication mode="Forms">
      <forms loginUrl="login.aspx" name=".ASPXCOOKIEAUTH2" protection="All" slidingExpiration="true" />
    </authentication>

The parseerror was occurring because the grid expected back JSON and got an HTML response. We added a client event to onError and tested out the error response. If we found out it was the login page we used e.preventDefault(); and then redirected the user to the login screen.
Tags
Grid
Asked by
Andri
Top achievements
Rank 1
Answers by
Sam Rossetti
Top achievements
Rank 1
Share this question
or