Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6952001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:17:31+00:00 2026-05-27T14:17:31+00:00

I am getting 401 – Unauthorised error in jQuery Autocomplete control in MVC3 application

  • 0

I am getting “401 – Unauthorised” error in jQuery Autocomplete control in MVC3 application (.net framework v4.0.30319) which is deployed on a server containing IIS 7.5

Controller: (SearchSuggestController)

    [HttpGet]
    public JsonResult SuggestByEmployeeId(string Id)
    {
        var suggestions = from a in Context.Employees
                          where a.EmployeeId.Contains(Id)
                          select new
                          {
                              a.EmployeeId,
                              a.FirstName,
                              a.LastName
                          };
        return Json(suggestions, JsonRequestBehavior.AllowGet);
    }

jQuery: (Autocomplete)

$(function () {
    $("#IDFilter").autocomplete({source: function (request, response) {
            $.ajax({
                url: "/SearchSuggest/SuggestByEmployeeId", 
                type: "POST", 
                dataType: "json",
                data: { Id: request.term },
                error: function (XMLHttpRequest, status, error) {
                    alert("Error status:(" + status + ") error:(" + error + ")");
                },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.EmployeeId, value: item.EmployeeId,id: item.EmployeeId };
                    }));
                }
            });
        },
        minLength: 3,
        autoFocus: true,
        select: function (event, ui) {
            $("#IDFilter").val(ui.item.value);
        }
    });});

jQuery is calling url: “/SearchSuggest/SuggestByEmployeeId” i.e. SearchSuggest controller’s
SuggestByEmployeeId action.

Search.cshtml:(View)

@using (Html.BeginForm("BasicSearch", "Employee"))
{
 @Html.Label("Employee Id:")
 @Html.TextBox("IDFilter")
<input type="submit" value="Search" />
}

BasicSearch action method in Employee controller is working fine if valid EmployeeID is entered in “IDFilter” and clicked on Search button.

Autocomplete is showing expected results when i run the code through visual studio IDE. After publishing and Bin Deploying of this code to IIS 7.5 is throwing 401-Unauthorized error. The application is hosted under Default Web Site in IIS.

Anybody has any idea what is going wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:17:31+00:00Added an answer on May 27, 2026 at 2:17 pm

    I think i have got a solution.

    Digging into jQuery using IE8 Developer Tools

    On host server, the autocomplete XMLHttpRequest is trying to search for Request URL "http://localhost:80/SearchSuggest/SuggestByEmployeeId?Id=123"

    But my application is hosted as “MyApp” under Default Web Site, so the URL should be like "http://localhost:80/MyApp/SearchSuggest/SuggestByEmployeeId?Id=123"

    Hence i have updated the URL to url: "/MyApp/SearchSuggest/SuggestByEmployeeId"

    After this change Autocomplete is fetching the expected results. 401 error is gone.

    Probably in host environment, i will have to setup a new web site and bin deploy my MVC application under that.
    This way i don’t need to make this modification in jQuery everytime.

    If anyone has got a better solution, please suggest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
I have an example where i am getting an 401 error because the consumer
I'm getting a 401 constantly without further explanation of what the error is when
I have setup an ASP.NET MVC3 website using Windows Authentication and am getting a
I am getting a 401 unauthorized error when I try to read an XML
I keep getting 401 when trying to login via Oauth with Twitter. I'm using
Getting started with jquery and having trouble getting hello world type example going for
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.