【问题标题】:Form authentication with jqgrid in asp.net在 asp.net 中使用 jqgrid 进行表单身份验证
【发布时间】:2012-01-05 11:02:31
【问题描述】:

我正在使用 jqgrid,点击 jqgrid 会在同一页面上打开表单。 我也在其中使用 ASP.Net 用户身份验证。

问题是,当我单击网格行并且会话过期时。它以相同的形式打开登录页面,而不是切换到登录页面。

有人可以在这方面帮助我吗?

这是我的 jqgrid 代码:

$(document).ready(function () {

    $(':checkbox').click(function () {
        var value = $("#cb").is(":checked");
        $("#document-grid").jqGrid('setGridParam', { datatype: function (postdata) {
            $.ajax({
                type: "POST",
                url: "/Calls/Documents.aspx/Find?showarchive=" + value,
                data: JSON.stringify($.extend({ 'filters': '' }, postdata)),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (res) {
                    $("#document-grid")[0].addJSONData(res.d);
                }
            });
        }
        }).trigger("reloadGrid", [{ current: true}]);
    });

    $("#document-grid").generalGrid({
        url: '/Calls/Documents.aspx/Find',
        jqGridOptions: {
            pager: '#document-grid-pager',
            colNames: ['Titel', 'Uploaddatum', 'Omschrijving', 'Bestandsnaam'],  //, 'Type' ],
            colModel: [
                    { name: 'Titel', index: 'Title' },
                    { name: 'Uploaddatum', index: 'Uploaddatum', sorttype: 'date', searchoptions: {
                            dataInit: function (elem) {
                                $(elem).datepicker({
                                    onSelect: function(dateText, inst){ $("#document-grid")[0].triggerToolbar(); }
                                });
                            },
                        }
                    },
                    { name: 'Beschrijving', index: 'Description' },
                    { name: 'Bestandsnaam', index: 'Filename' }
            //                    { name: 'Type', index: 'Type' }
                ],
            sortname: 'UploadDate',
            caption: '',
            onSelectRow: function (Id) {
                alert(Id);
                $("#document-form").box('destroy').ajaxFormPanel('destroy').ajaxFormPanel({ url: '/Forms/Document.aspx?Id=' + Id,
                    loaded: function (s) {
                        $("#txtUploadDate, #txtExpirationDate", s.element).datepicker();
                        $(s.element).box({ title: 'Document bewerken' });
                    },
                    postback: function (s) {
                        $("#document-grid").trigger("reloadGrid", [{ current: true}]);
                        // $("#document-form").ajaxFormPanel('destroy').ajaxFormPanel({ url: '/Forms/Document.aspx?Edited=true&Id=' + Id }).ajaxFormPanel('open');                    
                    }
                }).ajaxFormPanel('open');
            }
        }
    });

我在 Web.config 中的用户身份验证代码是:

<authentication mode="Forms">
  <forms loginUrl="Login.aspx"
         protection="All"
         timeout="1"
         name=".ASPXFORMSAUTH"
         path="/"
         requireSSL="false"
         slidingExpiration="true"
         defaultUrl="Default.aspx"
         cookieless="UseDeviceProfile"
         domain=""
         enableCrossAppRedirects="false" />
</authentication>

提前谢谢..

【问题讨论】:

    标签: asp.net jqgrid forms-authentication jqgrid-asp.net


    【解决方案1】:

    我想你可以检查 http 响应的返回码 301(重定向)。像

    if (response.status == 301)
    {
        document.location = "login.aspx";
        return;
    }
    load jqgrid normally.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-12
      • 2013-08-11
      • 1970-01-01
      相关资源
      最近更新 更多