Object Moved error while consuming a webservice

Posted by NandaGopal on Stack Overflow See other posts from Stack Overflow or by NandaGopal
Published on 2010-04-14T13:02:27Z Indexed on 2010/04/14 13:03 UTC
Read the original article Hit count: 962

Filed under:

Hi - I've a quick question and request you all to respond soon.

I've developed a web service with Form based authentication as below.

1.An entry in web.config as below.

2.In Login Page user is validate on button click event as follows.

if (txtUserName.Text == "test" && txtPassword.Text == "test")

        {

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, // Ticket version

                txtUserName.Text,// Username to be associated with this ticket

                DateTime.Now, // Date/time ticket was issued

                DateTime.Now.AddMinutes(50), // Date and time the cookie will expire

                false, // if user has chcked rememebr me then create persistent cookie

                "", // store the user data, in this case roles of the user

                FormsAuthentication.FormsCookiePath); // Cookie path specified in the web.config file in <Forms> tag if any.

            string hashCookies = FormsAuthentication.Encrypt(ticket);

            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies); // Hashed ticket

            Response.Cookies.Add(cookie);

            string returnUrl = Request.QueryString["ReturnUrl"];

            if (returnUrl == null) returnUrl = "~/Default.aspx";

            Response.Redirect(returnUrl);

        }

3.Webservice has a default webmethod.

[WebMethod]

    public string HelloWorld()

    {      

            return "Hello World";            

    }

4.From a webApplication I am making a call to webservice by creating proxy after adding the webreferance of the above webservice.

          localhost.Service1 service = new localhost.Service1();



            service.AllowAutoRedirect = false;

            NetworkCredential credentials = new NetworkCredential("test", "test");

            service.Credentials = credentials;




            string hello = service.HelloWorld();

            Response.Write(hello);

and here while consuming it in a web application the below exception is thrown from webservice proxy.

-- Object moved

Object moved to here.

--.

Could you please share any thoughts to fix it?

© Stack Overflow or respective owner

Related posts about webservices