Get “Not Authorised” error when accessing Web Service through AutoCompleteExtender

Last post 07-16-2009 7:11 PM by a.amitshah. 2 replies.

Sort Posts:

  • Get “Not Authorised” error when accessing Web Service through AutoCompleteExtender

    07-14-2009, 1:29 AM
    • Member
      point Member
    • a.amitshah
    • Member since 07-14-2009, 1:13 AM
    • Posts 2

    Hi,

    I am trying to implement Auto Complete feature in my website.

    I have added the AutoCompleteExtender in my web page and I have also assigned a TargetControlID.

    When I start typing in letter, it attempts to call the web service, but for some reason I get an error “Not authorized”. I catch that error in Global.ascx (Application_Error).

    I am using Windows Authentication for the website.

    I am using .NET Framework 2.0 with Visual Studio 2008.

    Here is what my web service looks like:


    /// <summary>
        /// Summary description for WebService2
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [ToolboxItem(false)]
        [System.Web.Script.Services.ScriptService]
        public class WebService2 : System.Web.Services.WebService
        {

            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }

            [WebMethod]
            [System.Web.Script.Services.ScriptMethod]
            public string[] GetCompletionList(string prefixText, int count)
            {
                if (count == 0)
                {
                    count = 10;
                }

                if (prefixText.Equals("xyz"))
                {
                    return new string[0];
                }

                Random random = new Random();
                string[] items = new string[20];

                for (int i = 0; i < count; i++)
                {
                    char c1 = (char)random.Next(65, 90);
                    char c2 = (char)random.Next(97, 122);
                    char c3 = (char)random.Next(97, 122);

                    items[i] = prefixText + c1 + c2 + c3;

                    //items.Add(prefixText + c1 + c2 + c3);
                }
                return items;
            }
        }

    Any help would be appreciated.

    Thanks.

    Amit

  • Re: Get “Not Authorised” error when accessing Web Service through AutoCompleteExtender

    07-14-2009, 11:07 AM
    • Star
      7,932 point Star
    • amit.jain
    • Member since 10-06-2008, 5:09 AM
    • Delhi India
    • Posts 1,264

    Refer this

    http://csharpdotnetfreak.blogspot.com/2009/01/ajax-autocomplete-textbox-gridview.html


    btw i m not able to find constructor of the class ? , this might be causing error

    Don't say thanks rather mark my reply as "Answer" if it helps you ,Doing so u'll get points too
    amiT jaiN

    ASP.NET C#.NET Articles
  • Re: Get “Not Authorised” error when accessing Web Service through AutoCompleteExtender

    07-16-2009, 7:11 PM
    • Member
      point Member
    • a.amitshah
    • Member since 07-14-2009, 1:13 AM
    • Posts 2

    Thanks for that.

    I have managed to fix the problem.

    I have added different rules so that users can access only a few pages and apparently I had not set any rule for my webserivce hence it was failing.

    Thanks

    Amit Shah


Page 1 of 1 (3 items)