Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I use thirt-party component which need to call asmx webservice. That is why I need to use asmx not webapi.
There is an 401 Unauthorized error. For testing I've created
/json/menuextended.asmx
namespace UmbracoCMS.json{ [WebService(Namespace = "UmbracoCMS.json")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][ScriptService] public class menuextended : WebService { [WebMethod(EnableSession = true)] [ScriptMethod] public string loadmenu() { return "1111"; } }}
<script type="text/javascript"> $(document).ready(function() { $.ajax({ type: "GET", url: "/json/menuextended.asmx/loadmenu", contentType: "application/json", dataType: "json", success:function (data){ alert("ok"); }, error: function (data){ alert("error"); } }); }); </script>
I've got an error 401 Unauthorized. When I used UmbracoAuthorizedWebService and UmbracoWebService situation was the same. Where is the mistake?
If I call it by link http://localhost:29000/json/menuextended.asmx/loadmenu everythink is ok
Ok, additional info: we use cluster for Umbraco backoffice. And I wrote to web.config
<sessionState cookieless="true" mode="StateServer" stateConnectionString="tcpip=job.trunk.ozon:42424" timeout="60" useHostingIdentity="false"/>
cookieless="true" -- because without of this parameter angular.js didn't send cookie to server and Umbraco thought that it was unauthenticated user. But ajax-call can't redirect from http://localhost:29000/json/menuextended.asmx/loadmenu to http://localhost:29000/(SessionID)/json/menuextended.asmx/loadmenu and show me "401 unauthorized" . If I return cookieless="false" everythink work ok. In my case the decision was:
If you use ajax jquery post call with contentType: "application/json" don't use cookieless="true" for backofiice state server.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Call asmx: 401 Unauthorized
Hello,
I use thirt-party component which need to call asmx webservice. That is why I need to use asmx not webapi.
There is an 401 Unauthorized error. For testing I've created
/json/menuextended.asmx
I've got an error 401 Unauthorized. When I used UmbracoAuthorizedWebService and UmbracoWebService situation was the same. Where is the mistake?
If I call it by link http://localhost:29000/json/menuextended.asmx/loadmenu everythink is ok
Ok, additional info: we use cluster for Umbraco backoffice. And I wrote to web.config
cookieless="true" -- because without of this parameter angular.js didn't send cookie to server and Umbraco thought that it was unauthenticated user. But ajax-call can't redirect from http://localhost:29000/json/menuextended.asmx/loadmenu to http://localhost:29000/(SessionID)/json/menuextended.asmx/loadmenu and show me "401 unauthorized" . If I return cookieless="false" everythink work ok. In my case the decision was:
If you use ajax jquery post call with contentType: "application/json" don't use cookieless="true" for backofiice state server.
is working on a reply...