Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:24:46+00:00 2026-06-13T14:24:46+00:00

I want to pass data user Id and user code to another server and

  • 0

I want to pass data user Id and user code to another server and get the response using network.

So, I created this code

var webRequest = WebRequest.Create(@"http://10.2.1.85/");

It is working fine but I don’t know how to pass the user Id and user code.

Do I have to create object or something?

How can I do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:24:47+00:00Added an answer on June 13, 2026 at 2:24 pm

    This is how to Post Data on Web Service:

    WebService Post Function

    public static string JsonPost(string url, string method, string postData)
    {
    
        Uri address = new Uri(url + method);
    
        //Get User current network credential
        ICredentials credentials = CredentialCache.DefaultCredentials;
        NetworkCredential credential = credentials.GetCredential(address, "Basic");
    
        HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
        request.Method = "POST";
        request.ContentType = "application/json";
    
        //Network Credential should be included on the request to avoid network issues when requesting to the web service
        request.Proxy = WebRequest.DefaultWebProxy;
        request.Credentials = new NetworkCredential(credential.UserName, credential.Password, credential.Domain);
        request.Proxy.Credentials = new NetworkCredential(credential.UserName, credential.Password, credential.Domain);
    
        byte[] byteData = UTF8Encoding.UTF8.GetBytes(postData);
        request.ContentLength = byteData.Length;
        using (Stream postStream = request.GetRequestStream())
        {
            postStream.Write(byteData, 0, byteData.Length);
        }
    
        using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
        {
            StreamReader reader = new StreamReader(response.GetResponseStream());
    
            string JsonResponse = reader.ReadToEnd();
    
            return JsonResponse;
        }
    }
    

    Login Function

    public static string Login(string Email, string Password)
    {
    
        try
        {
            string postData = "{" + "\"Email\":\"" + Email + "\"," +
            "\"Password\":\"" + Password + "\"" +
            "}";
    
            string JsonResult = JsonPost("Your Web Service URL", "Login", postData);
            return JsonResult;
        }
        catch (Exception ex)
        {
    
            return "";
        }
    
    }
    

    Example How To Use:

    public void LoginUser()
    {
        string Email = "me@example.com";
        string Password = "password";
        string JsonUserAccount = Login(Email, Password);
    
        if(!string.IsNullOrEmpty(JsonUserAccount))
        {
            Debug.Print("User logged in");
        }
        else
        {
            Debug.Print("Failed to logged in");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass data from second tab to first tab using delegates.But delegate
I want to pass data between a Python and a C# application in Windows
I want to pass data from database to JSF page as a table. I
I have two pages and I want to pass data to each other. How
i have two flex applications and i want to pass the data from one
I have an NSMutableArray of names. I want the pass the data (selected name)
I am writing an android app. I want to pass some data across the
My data is just number, I want pass it from VC1 to VC2 for
I know how to pass data from one activity to another. But what I
Hi i want to pass a data from my char device driver to serial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.