Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
public MainPage()
        {
            InitializeComponent();
            StringBuilder postData = new StringBuilder();
            WebClient webClient = new WebClient();
            var tsLong = DateTime.Now.Millisecond / 1000; 
            webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            var uri = new Uri("URL");

            postData.AppendFormat("{0}={1}", "className", HttpUtility.UrlEncode("ebuskiMobile"));
            postData.AppendFormat("{0}={1}", "methodName", HttpUtility.UrlEncode("m_getContents"));
            postData.AppendFormat("{0}={1}", "osName", HttpUtility.UrlEncode("Windows"));
            postData.AppendFormat("{0}={1}", "osVersion", HttpUtility.UrlEncode("1.0"));
            postData.AppendFormat("{0}={1}", "appVersion", HttpUtility.UrlEncode("1.0"));
            postData.AppendFormat("{0}={1}", "width", HttpUtility.UrlEncode("1080"));
            postData.AppendFormat("{0}={1}", "height", HttpUtility.UrlEncode("1200"));
          

            webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadRegisterStringCompleted);
            //    webClient.UploadProgressChanged += webClient_UploadRegisterProgressChanged;
            webClient.UploadStringAsync(uri, "POST", postData.ToString());
        }

        public class RootObject
        {
            public string message { get; set; }
        }
        private void webClient_UploadRegisterStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {

//exeption here
            string jsonstring = e.Result;
            RootObject rootobj = new RootObject();
            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonstring));
            DataContractJsonSerializer ser = new DataContractJsonSerializer(rootobj.GetType());
            rootobj = ser.ReadObject(ms) as RootObject;
            string status = rootobj.message;
            MessageBox.Show(status);
          //  NavigationService.Navigate(new Uri("/MISTFMGE;component/Views/Login.xaml", UriKind.RelativeOrAbsolute));
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
          
        }



        private void btnSkip_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(
            new Uri("/EntryPoll.xaml", UriKind.Relative));
        }



    }
Posted
Updated 21-Sep-15 21:18pm
v5
Comments
George Jonsson 22-Sep-15 3:13am    
You have posted an error message, but not a question.
On which line does the error occur?
itskumarvikas 22-Sep-15 3:17am    
string jsonstring = e.Result;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900