Base solution for your next web application
Open Closed

abp.ajax You are not authenticated! #8737


User avatar
0
AstarIT created

I have big issues here with the abp.ajax. I cannot find documentation about it. just the one is on the asp.net zero site. second I am using it and I get this following errors //Get States select controls added by Cesar [AbpAuthorize(AppPermissions.Pages_Administration_TenantExtendeds)] [HttpPost] [WrapResult(WrapOnSuccess = false, WrapOnError = false)] public List<NameValue<string>> GetAllStates(int Id) { var states = _stateRepository.GetAll().ToList().Where(m => m.CountryId == Id); var stateslist = new List<NameValue<string>>(); foreach (var item in states) { stateslist.Add(new NameValue { Name = item.Name, Value = item.Id.ToString() });

		}

		return  stateslist.ToList();

	}
	// end States by Cesar

This is the Ajax // Country State $(document).ready(function () { debugger; var country = $("#CountryId"); var state = $("#StateId"); state.prop("disabled", true);

country.change(function () {
    if ($(this).val() == "0") {
        state.prop("disabled", true);
        state.val("0");
        console.log($(this).val());
    }
    else {
        debugger;
        abp.ajax({
            
            url: abp.appPath + "api/services/app/TenantExtendeds/GetAllStates?Id=" + $(this).val(),
            method: "Post",
            
            success: function (data) {
                state.prop("disabled", false);
                state.empty();
                
                $(data).each(function (index, item) {
                    state.append($('&lt;option/&gt;', { value: item.id, text: item.Name }));

                });
            }
        });
    }
});

});

I have the following errors Missing type map configuration or unsupported mapping

AutoMapper.AutoMapperMappingException HResult=0x80131500 Message=Missing type map configuration or unsupported mapping. Source=<Cannot evaluate the exception source> StackTrace: <Cannot evaluate the exception stack trace>

"Error detail not sent by server." "You should be authenticated (sign in) in order to perform this operation." "You are not authenticated!" "You are not allowed to perform this operation." "The resource requested could not found on the server."

Any help here will be really appreciated Thank you


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you try using AbpMvcAuthorize instead of AbpAuthorize ? Could you also share the entire error message about AutoMapper ? It is hard to understand the exact problem with this message.

  • User Avatar
    0
    AstarIT created

    Thank you that works the first time then I go the browser disconnection using DEVTOOLS. Crome was disconecting so I did a little research and I found out that there is an issue with Crome and instead use Crome Canary which I did. Now it working fine however I am still need to use CROME. Have you enconter such a problem,if so let us know. Thank you.

    This is the code $(document).ready(function () { debugger; var country = $("#CountryId"); var state = $("#StateId"); state.prop("disabled", true);

    country.change(function () {
        if ($(this).val() == "0") {
            state.prop("disabled", true);
            state.val("0");
            console.log($(this).val());
        }
        else {
          //  debugger;
            abp.ajax({
    
                url: abp.appPath + "api/services/app/TenantExtendeds/GetAllStates?Id=" + $(this).val(),
                method: "Get",
                dataType: "Json",
                data: JSON.stringify(url),
                success: function (data) {
                    state.prop("disabled", false);
                    state.empty();
    
                    $(data).each(function (index, item) {
                        //state.append($('&lt;option/&gt;', { value: item.id, text: item.Name }));
                        state.append("&lt;option value=&#39;&quot; + item.id + &quot;&#39;&gt;" + item.name + "&lt;/option&gt;")
                    });
                    
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    console.log(textStatus, errorThrown);
                    console.log(data);
                }
    
            });
                       
        }
    });
    

    });

    Thank you have a good day. Greetings.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Probably there is a stored cookie in Google Chrome. You can try to clear site data and try this again.