Eliminate authentication error

Symptom:
Some users cannot POST successfully, most of them can POST successfully.
When an error occurs, users are redirected to the share / error page.

Technologies used:
IIS v6
Windows Server 2003
asp.net v3.5
asp.net mvc framework v1.0
JQuery

LINQ sql server 2005

Authentication: Windows with the AspNetActiveDirectoryMembershipProvider
Here is a snippet of the web.config file:

<authentication mode="Windows"/>
    <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
    <providers>
            <add name="AspNetActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,&#xA;                 System.Web, Version=2.0.3600.0, Culture=neutral,&#xA;                 PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnString" connectionUsername="" connectionPassword=""/>
        </providers>
    </membership>

      

Here's a link from a perspective that triggers the Save button <a href="javascript:void(document.frmCurrentLineItems.submit())" title="Saves this month only">Save This Month</a>

Here are some jQuery based javascript:

$("form#frmCurrentLineItems").submit(function() {
    submitView(this);
    return false;
});

function submitView(form) {        
    $.ajax(
            {
                type: form.method,
                url: form.action,
                data: $(form).serialize(),
                dataType: "html",
                error: function(error) {
                    alert(error);
                }
            }
        );
}

      

Here's part of the controller method:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CurrentLineItems(FormCollection thisForm)
    // Get the forecast from the session
    BusinessLogic.ForecastBL thisForecast = (BusinessLogic.ForecastBL)HttpContext.Session["ForecastMetaData"];

        if (thisForecast != null)
        {
            // Run the save to db stuff here
            return View("CurrentLineItems", ViewData["LineItemSummary"]);
        }
        else
        {
            return Redirect("../Shared/Error");
        }

      

A note on the above code ... I'm pretty sure pulling the projection object out of the session doesn't throw an error, at least I'm guessing it's not because the session has expired, because users that can't save can't save when they open the page and then immediately try to save.

The class also has the following attributes:

[HandleError]
[Authorize]
public class ForecastController : Controller
{

      

The site has IIS properties in the authentication methods:
Enable Forbidden Anonymous Access and Integrated Windows Authentication is enabled.

See the IIS log here from a user experiencing this issue:

466 2009-04-28 16:41:15 W3SVC1100645706 192.168.10.22 POST / Forecast / CurrentLineItems - 443 - XX.XX.XX.XX Mozilla / 4.0 + (compatible + MSIE + 7.0; + Windows + NT + 5.1; + GTB5 ; + .NET + CLR + 1.1.4322) 401 1 0
467 2009-04-28 16:41:15 W3SVC1100645706 192.168.10.22 POST / Forecast / CurrentLineItems - 443 DOMAIN \ username XX.XX.XX.XX Mozilla / 4.0 + (compatible; + MSIE + 7.0; + Windows + NT + 5.1; + GTB5; + .NET + CLR + 1.1.4322) 302 0 0
468 2009-04-28 16:41:15 W3SVC1100645706 192.168.10.22 GET / Shared / Error - 443 - XX.XX.XX.XX Mozilla / 4.0 + (compatible; + MSIE + 7.0; + Windows + NT + 5.1; + GTB5; + .NET + CLR + 1.1.4322) 401 1 0
469 2009-04-28 16:41:16 W3SVC1100645706 192.168.10.22 GET / Shared / Error - 443 DOMAIN \ username XX.XX.XX.XX Mozilla / 4.0 + (compatible; + MSIE + 7.0; + Windows + NT + 5.1; + GTB5; + .NET + CLR + 1.1.4322) 404 0 0

Here the same lines have been split for reliable readability:
2009-04-28 16:41:15 POST / forecast / CurrentLineItems - 443 - XX.XX.XX.XX 401 1 0
2009-04-28 16:41:15 POST / Forecast / CurrentLineItems - 443 DOMAIN \ username XX.XX.XX.XX 302 2009-04-28 16:41:15 GET / Shared / Error - 443 - XX.XX. XX.XX 401 1 0
2009-04-28 16:41:16 GET / Shared / Error - 443 DOMAIN \ username XX.XX.XX.XX 404 0 0

Just noticed that all POST requests look like above ... except for successfully returning 200 on the second POST ...

So how do I determine what triggers the first POST above ... the one that does it on the webserver without DOMAIN \ username and gets a 401 error?

Also why error 302?

It looks like I'm asking for two POSTS ... but I don't quite understand why the browser is sending two POST requests? (of course ... I suspect my code, but can't figure out why.)

It is understood that any troubleshooting methods to help track down the above errors would be appreciated.

Now take a look at Troubleshooting HTTP 401 Errors in IIS Edit .... it didn't really help me / my problem

0


source to share


2 answers


Changing the link to the input button / element seems to have solved this problem ...
<input type="submit" value="Save This Month" title="Saves this month only" class="submitBtn"/>



Since the enter button is inside the form I want to submit ... it hits the Post controller action and saves the data and then displays the view ...

0


source


The first 401s you return are part of the NTLM authentication scheme, since IIS handles Windows authentication. The request is made, it returns 401, so it tries again to send NTLM authentication information.

So your first message comes in, gets a 401, then tries again with authenticated and gets a 302. This is your redirect to an error page. Then your error pages get 401, try again and get 404.



So you have two problems, the first is your controller error. It could be a null check redirect or it could be another error, are you logging your errors? Also, I would choose an exception instead of a redirect. Then your handleError logic should drive in and handle it for you.

Second, it looks like your error page doesn't exist or your routing is messed up.

+2


source







All Articles