views:

158

answers:

1
+2  A: 

Could it be because when you switched it to AJAX that you didn't preserve the POST HTTP method?

When I tried replacing the Html.BeginForm line with this one, it worked:

<% using (Ajax.BeginForm("LogOnPostAssertion", "Auth", new AjaxOptions { HttpMethod = "POST" })) { %>

By setting a breakpoint on the LogOnPostAssertion action, I saw that it did work. But the action itself would need to be adjusted to not send redirects but rather send whatever update script is appropriate.

Andrew Arnott
In my case the method should be called from popup dialog that contents is loaded dynamically. So the process is:1. User clicks login link.2. The AJAX call make to the site and loads logOn form. The form is loaded in hidden div and popup is shown to the user.3. The user clicks Google icon. The window appeared with a prompt for credentials.4. The user enters credentials. The form is closed. And the form should be submitted but it does not happened in my case.It is probably because of ajax loading.
lostaman
I've also noticed several interesting things. 1. Javascript function 'postLoginAssertion' is responsible for form submitting, but it is not called in my case.2. When SelectorOpenId button is renders it has a link with href="#". I wonder why anchor appears there? It seems that this causing my site to redirect to home page as I use anchors for saving history.
lostaman
I use an `href="#"` here so that (as I recall) browsers treat these `A` tags as links, despite the fact that they invoke javascript instead of jumping to a new page. Your flow doesn't sound significantly different from what I tried and saw worked. Perhaps you can check for javascript runtime errors to see if postLoginAssertion isn't invoked due to an earlier failure?
Andrew Arnott
Ok. I finally resolved the problem and it is works now. You were right, the problem was in my scripts. The only problem I have is that when Google widow is opened I often can see the error in alert TypeError: Object expected. But login is processed successfully. I wonder why this error can occur?After this error I have error in my site code that li.loginBackground() method is undefined. Where this method is declared?
lostaman
The OpenIdSelector.js file defines `li.loginBackground` on each button your selector has. I don't know if it's related, but I noticed your ASPX code adds both a Google OP button and an OpenID button with the Google logo. That seems wrong to me. Typically the OpenID button uses the OpenID logo, so the user can distinguish between the two buttons.
Andrew Arnott
I've added it just for testing purpose. It was strange to me but I must use SelectorOpenIdButton, otherwise I receive script errors because rendered by Html.OpenIdSelectorScripts script cannot find the element rendered by this button. Therefore I render it and hide by CSS. BTW where can I find OpenIdSelector.js file?
lostaman
The OpenIdSelector.js file is embedded within DotNetOpenAuth.dll, but you can see it here (http://github.com/AArnott/dotnetopenid/blob/v3.4/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.js). The bug you describe where you have to have that button to avoid js errors sounds like one I've fixed in a more recent version. Are you using the latest version of DotNetOpenAuth?
Andrew Arnott
I'm using the latest version available on the site (3.4.5.10202). If I remove SelectorOpenIdButton from my example I getting the error "'undefined' is null or not an object" in script while executing the following statement: box.dnoi_internal={postback:postback}; (box is undefined)
lostaman
great to know. I'll get that fixed.
Andrew Arnott