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

  • SEARCH
  • Home
  • 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 9000555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:19:33+00:00 2026-06-16T00:19:33+00:00

I have a Piece of code which works perfect in .NET (4.0) Code# string

  • 0

I have a Piece of code which works perfect in .NET (4.0)

Code#

        string URI = "http://www.indianrail.gov.in/cgi_bin/inet_pnrstat_cgi.cgi";
        string Parameters = Uri.EscapeUriString("lccp_pnrno1=8561180607&submitpnr=Get Status");
        System.Net.HttpWebRequest req = (HttpWebRequest)System.Net.WebRequest.Create(URI);
        //HTTP POST Headers
        req.ContentType = "application/x-www-form-urlencoded";
        req.Host = "www.indianrail.gov.in";
        //You can use your own user-agent.
        req.UserAgent = "Mozilla/5.0 (compatible; MSIE 7.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0) DELL;Venue Pro";
        req.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-us,en;q=0.5");
        req.Headers.Add(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
        req.KeepAlive = true;
        req.Referer = "http://www.indianrail.gov.in/pnr_stat.html";
        req.Accept = "text/plain";
        req.Method = "POST";
        //Byte size calculation before sending request.
        byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
        req.ContentLength = bytes.Length;
        System.IO.Stream os = req.GetRequestStream();
        os.Write(bytes, 0, bytes.Length);
        os.Close();
        System.Net.WebResponse resp = req.GetResponse();
        var request_status = ((HttpWebResponse)resp).StatusDescription;
        if (resp == null) return;
        System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
        Console.WriteLine(sr.ReadToEnd());
        Console.ReadLine();  

I just cant Seem to figure out what to write in Win Store apps

SO far i have got to which class i have to use (or may be not)

HttpClient httpClient = new HttpClient();

httpClient.DefaultRequestHeaders.Add("Host", "www.indianrail.gov.in");  

But what about the other values there are some header in which we can add some data ,some are there which need to be added to the collection (DefaultHeaders) directly…

Is there any documentation for usage and description for the same

ANy help in this direction will be great 🙂

  • 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-16T00:19:34+00:00Added an answer on June 16, 2026 at 12:19 am

    Any ways thanks for help from the community…. some reading led me to figure out this solution

                string URI = "http://www.indianrail.gov.in/cgi_bin/inet_pnrstat_cgi.cgi";
                string Parameters = Uri.EscapeUriString("lccp_pnrno1=8561180604&submitpnr=Get Status");
    
                HttpClient client = new HttpClient();
    
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post,URI);
    
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));
                request.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8",0.7));
                request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-us",0.5));
                request.Content = new StreamContent(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Parameters)));
                request.Content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                request.Headers.Host = "www.indianrail.gov.in";
                request.Headers.UserAgent.Add(new ProductInfoHeaderValue("Mozilla", "5.0"));
                request.Headers.Referrer = new Uri("http://www.indianrail.gov.in/pnr_stat.html");
    
                var result = await client.SendAsync(request);
                var content = await result.Content.ReadAsStringAsync();  
    

    This returns exactly the result i wanted

    Thanks ne ways

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code which works 90% of the time: $user_details=$fb->api_client->users_getInfo($fb_user, array('last_name','first_name','proxied_email'));
I have a piece of code which works in a way that is unexpected
I have a piece of code related to MapKit which works fine on my
I have this piece of code which works, however I would like to change
I have this little piece of jQuery/jqModal code which works fine. However, I am
I have a piece of code that works in a background process which looks
I have this piece of code which works in Firefox link = $('<a>link</a>'); var
I have this piece of code which compiles and works as expected: #include <iostream>
I have the below piece of code which Prefixs a string to the start
I have a piece of code below which works fine when it comes to

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.