none
'System.Net.HttpWebRequest' does not contain a definition for 'AllowAutoRedirect' Winphone 8.1 RRS feed

  • Question

  •  i have a API in my project winphone siverlight 8.1 but when I  rewriting  to winphone 8.1 have erro 

    ******************************

    public async Task<bool> Login(String username, String password)
            {

                bool has_token = await this.get_token();
                if (!has_token)
                    return false;
                System.Diagnostics.Debug.WriteLine("=====Start Login=====");
                this.user.userName = username;

                string client_secret = "*****";
                string grant_type = "password";
                string client_id = "******";

                // string url_login = "https://dev.emotivcloud.com/dbapi/oauth/token/";

                try
                {
                    // Create a request using a URL that can receive a post. 
                    //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(this.els_url + "api-auth/login/"));               
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(this.els_url + "oauth/token/"));

                    // Set the Method property of the request to POST.
                    request.Method = "POST";
                    request.CookieContainer = new CookieContainer();
                    request.CookieContainer.Add(new Uri(this.els_url + "oauth/token/"), new Cookie("csrftoken", this.token));
                    request.CookieContainer.Add(new Uri(this.els_url + "oauth/token/"), new Cookie("sessionid", this.sessionid));
                    request.AllowAutoRedirect = false; ?????????(ERROR

    System.Net.HttpWebRequest' does not contain a definition for 'AllowAutoRedirect' and no extension method 'AllowAutoRedirect' accepting a first argument of type 'System.Net.HttpWebRequest' could be found (are you missing a using directive or an assembly reference?)

    )
                    request.Headers["Referer"] = this.els_url + "api-auth/login/";
                    request.ContentType = "application/x-www-form-urlencoded";

    Is any workaround how to fix it? Thank

    Thursday, January 22, 2015 4:24 AM

Answers

  • It appears that there's a documentation bug for this - it's not showing up as a supported method.  HttpWebRequest is an obsolete method though.  HttpClient is the way moving forward - can you try that?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by thoai.tl Saturday, December 12, 2015 5:10 PM
    Thursday, January 22, 2015 7:32 PM
    Moderator

All replies

  • It appears that there's a documentation bug for this - it's not showing up as a supported method.  HttpWebRequest is an obsolete method though.  HttpClient is the way moving forward - can you try that?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by thoai.tl Saturday, December 12, 2015 5:10 PM
    Thursday, January 22, 2015 7:32 PM
    Moderator
  • very grateful if you spend a little time to fix my problem 

    here is link to my test project winphone siverlight 8.1  // please run and see Output this run OK , see  Function login in ELSCLient.cs it have my proplem when i rewriting  to winphone 8.1 



    https://onedrive.live.com/?cid=3884B2A8CF74731C&id=3884B2A8CF74731C%21105



    thank !
    Saturday, January 24, 2015 6:57 AM