I am using the dll Ajax.Net Wraper. I manage to call a function from
the server, but when I try to use Forms Authentication , the call
doesnt work.
My Web.Config follows above:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
        <system.web>
                <httpHandlers>
                        <add verb="POST,GET" path="ajax/*.ashx"
type="Ajax.PageHandlerFactory, Ajax" />
                </httpHandlers>
                <compilation defaultLanguage="c#" debug="true" />
                <customErrors mode="RemoteOnly" />
                <authentication mode="Windows">
                        <forms name="Form1" loginUrl="WebForm1.aspx"
protection="All"
timeout="20" slidingExpiration="true" />
                </authentication>
                <authorization>
                                <deny users="?" />
                                <allow users="*" />

                        </authorization>


                        <trace enabled="false" requestLimit="10"
pageOutput="false"
traceMode="SortByTime" localOnly="true" />
                                <sessionState
                                mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"
                                sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
                                cookieless="false"
                                timeout="20" />
                        <globalization requestEncoding="utf-8"
responseEncoding="utf-8" />
        </system.web>
</configuration>


O codigo que utilizo para realizar a Forms Authentication é o
seguinte:


[Ajax.AjaxMethod()]
                public string Login(string login,string senha)
                {
                        string nome = "";
                        string grupo = "";
                        AutenticacaoAD auten = new AutenticacaoAD();
                        if(auten.AutenticacaoNoAD(ref nome,ref
grupo,login,senha))
                        {
                                FormsAuthenticationTicket authTicket =
new
FormsAuthenticationTicket(1, login,

DateTime.Now,DateTime.Now.AddMinutes(60),false, grupo);
                                // Now encrypt the ticket.
                                string encryptedTicket =
FormsAuthentication.Encrypt(authTicket);
                                // Create a cookie and add the
encrypted ticket to the
                                // cookie as data.
                                HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName,encryptedTicket);
                                // Add the cookie to the outgoing
cookies collection.
                                Response.Cookies.Add(authCookie);
                                // Redirect the user to the originally
requested page
                                //return
FormsAuthentication.GetRedirectUrl(login,false);
                                return "Default.aspx";
                        }
                        else
                        {
                                return "false";
                        }
                }


E o HTML :


function Logar()
                        {
                                var login = Form1.ttbLogin.value;
                                var senha = Form1.ttbSenha.value;
                                if(login != "" && senha != "")
                                        WebForm1.Login(login,senha,
Logar_CallBack);
                                else
                                {
                                        if(login == "")

document.all("lblValidadorLogin").innerHTML = "Please type your login";

                                        if(senha == "")

document.all("lblValidadorSenha").innerHTML = "Please type your
password";
                                }
                        }


                        function Logar_CallBack(response)
                        {
                                if(response.value != "false")
                                {
                                        location.href = response.value;

                                }
                                else
                                {

document.all("lblErro").innerHTML = "User or password incorrect";
                                } 
                        }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/
-~----------~----~----~----~------~----~------~--~---

Reply via email to