as

Friday 28 February 2014

The remote server returned an error: (500) Internal Server Error - While sending POST request C#

When you send the POST request to server, you may get the response from the server saying The remote server returned an error: (500) Internal Server Error.

This usually happens when you send the POST request with incorrect post data or wrong content Type.

To fix this issue you will have to see actual data being sent to particular URL using Google Chrome Developer Tools. You can open the developer tools using ctrl+shift+J in google chrome browser.
In network tab, you can see the GET and POST requests details along with response and cookies being transferred.

View POST request data in Chrome 
As you can see in above figure, the content type for the POST request is application/x-www-form-urlencoded

The Form data is email=gf&password=dfg&Submit=Login
If the data is encoded, you will have to use HttpUtility.UrlEncode method to encode the string.

Once you know actual data being sent to server you will have to send same data to server. You will have to also ensure that the CookieContainer is sent to the server to maintain the session.
Also make sure that you have contentType set as displayed in above figure.
To summarize, You will have to ensure below things to fix the internal server error.
  1. Before sending the post request, you will have to send the GET request. While sending the GET request, use the CookieContainer object to send/ receive the Cookies. Ensure that you use the same CookieContainer object while sending the following POST request. This will ensure that Server gets the required cookies.
  2. Ensure that POST data is encoded correctly.Sometimes the data is sent from the hidden fields. So you will have to send this data as well in form data.
  3. Ensure that your POST url is correct.
  4. Ensure that Content Type is correct.
If you still face the issue, you can contact me at reply2sagar@gmail.com

What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

How to send HTTP POST request to server in C#?

Below example shows how to send HTTP POST request to the web server in C#.Net

            String server= "http://www.ezybus.in";

            //create http web request.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(server);

            //if you use proxy server to connect  to the site, you will have to provide the server details and //authentication information.
            WebProxy myproxy = new WebProxy("proxy_server:8080", true);
            myproxy.Credentials = new NetworkCredential("userID", "Password");
            request.Proxy = myproxy;

            try
            {

                //3 things to send to server are - CookieContainer, PostData, ContentType

                request.Method = "POST";
             
                 String postData = "UserId=abc&UserPassword=bxnbs&enter=";
         
                 //encode post data
                 postData  = System.Web.HttpUtility.UrlEncode(postData);
             
                //here previousCookieContainer is the CookieContainer object that was used for the GET request
                request.CookieContainer = previousCookieContainer;
             
                 //convert the post data into byte array
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
             
                //set the ContentType property
                request.ContentType = "application/x-www-form-urlencoded";
             
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
               
                 //Send the POST request
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                //print the response code from the server
                Console.WriteLine(((HttpWebResponse)response).StatusDescription);

               

                dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);


               //print the response body received from the server
                string responseFromServer = reader.ReadToEnd();

                Console.WriteLine("Response of the post request is -> " + responseFromServer );

                dataStream.Close();
                response.Close();

             

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

When you send the POST request to the web server, you may get errors like session expired or Internal server error. To fix these issues, you can visit this solution.


What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

How to send HTTP GET/post requests through proxy in C#?

Below example demonstrates how we can send the GET or POST requests through proxy in C#.Net


                HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create("https://www.yahoo.com");


                //set the proxy server and authentication info for this request

                //provide the name of proxy server and port address
                WebProxy myproxy = new WebProxy("proxyserver:8080", true);

                //provide the user id and password for authentication to pass through proxy server
                myproxy.Credentials = new NetworkCredential("userId", "Password");
               getRequest.Proxy = myproxy;

               
                //send the request and get Response from server
                HttpWebResponse response = (HttpWebResponse)getRequest.GetResponse();
                Stream datastream = response.GetResponseStream();
                StreamReader reader = new StreamReader(datastream);

                String responsefromServer = reader.ReadToEnd();

Console.WriteLine("Response from the server is -> " + responsefromServer );

What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

How to send HTTP GET Request to server in C#?

Below example shows how we can create HTTP GET request in C#.

Remember that you will have to import below namespace.
using System.Net;                


                //create HTTP request. By default it is GET request

                HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create("https://www.google.com");


                //set the proxy server and authentication info for this request

                WebProxy myproxy = new WebProxy("proxyserver:8080", true);
                myproxy.Credentials = new NetworkCredential("userId", "Password");
               getRequest.Proxy = myproxy;

                //CookieContainer for maintaining session
                ck = new CookieContainer();
                getRequest.CookieContainer = ck;

       
                //send the request and get Response from server
                HttpWebResponse response = (HttpWebResponse)getRequest.GetResponse();
                Stream datastream = response.GetResponseStream();
                StreamReader reader = new StreamReader(datastream);

                String htmlResponse = reader.ReadToEnd();

Console.WriteLine(" Response of the server is -> " + htmlResponse );



What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

Wednesday 26 February 2014

data type mismatch in criteria expression in ms access

Problem / Error:

When you try to access the data from the Microsoft Access database from any language like C#, VB.Net, VB6 etc, You may encounter the error saying - data type mismatch in criteria expression .
This happens when you are executing the query involving the column with data type set as Date/Time in access database.

For example -Consider below query.

Select * from student where joining_date = '12-01-2013' 

Executing above query will give you the error saying data type mismatch in criteria expression.

Solution:
To fix above issue, you will have to re-write the query as mentioned below.

Select * from student where joining_date = #12-01-2013#

Thus we have to use # at the start and end of the date value. This will fix the issue.


What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

Can't find DAO350.DLL file Error in Vb6

Problem/Error

When you try to open visual basic application in windows 7, You may get the error saying Visual Basic can not find the DAO350.DLL file.

The reason for this error is that in windows 7, new version of file is installed - dao360.dll
You can view this file at below location on windows 7.
C:\Program Files\Common Files\microsoft shared\DAO

In windows XP, this file exists, So you will not get this error.

Solution
To fix this issue, you will have to search for the DAO350.dll file in the visual basic installation folder.
Then copy this file to the below location.
C:\Program Files\Common Files\microsoft shared\DAO

After this you will have to register this file using below command in the command prompt.

regsvr32 "c:\program files\common files\microsoft shared\dao\dao350.dll"

Please note that you will have to run command prompt as administrator. To run command prompt as the administrator, you will have to right click and then click on the "Run as Administrator"

After you run above command you should get the dll register successful message.
If you do not run the command prompt as Administrator,     You will get error saying module was loaded but call to dllregisterserver failed.

What do you think on this topic? Please express your opinion through comment below. You can write to me at reply2sagar@gmail.com

Tuesday 25 February 2014

Training Institute Management System project in VB6

In this article I am going to show how you can develop the software project for management of the training institute in VB6


Training Institute Management System - Project Synopsis

This project involves development of training institute management software viz Softzone using vb 6.0. Many training institutes need to manage the student’s data like enquiry calls, admission data, payments data etc. Generally training institutes store the information in the excel sheet. But they need more accurate way to store the data. Admin is also interested in knowing the courses in demand. He also wants to view the reports.
So to enable them to manage this data we are developing this software called Softzone. Softzone will have all features that will help training institute administrator to manage institute data.

The requirements to be fulfilled by the software are mentioned below.
End users of the Softzone will be training institute administrators. So here is the list of requirements of Softzone.

  1. Admin should be able to capture the enquiries from the students like e-mail id, permanent address, student name ,  course, enquiry date  etc
  2. Whenever students take admission to any course, admin should be able to enter admission related information to the database like course name, student name, student mobile, email address, joining date.
  3. Whenever students make the payments, that information will be stored in database for future reference.
  4. Information about course name, duration, fees should be stored in some tables.
  5. Admin should be able to view the reports like how many students took admission in particular month or year.
  6. Similarly he should be able to view enquiries and payments report.


Project Technology, Hardware and Software Specification: 
We will need below hardware configuration.
Windows PC with 256 MB RAM 

We will need below software configuration.
Visual Basic 6.0
Microsoft Office – Ms Access, Ms Word

Training Institute Management System - Project design

Below figure illustrates how data flows in the system.

Training institute management system in VB6

Training Institute Management System - Pros and Cons

Advantages of Training Institute Management System -
:
  1. Administrators of institutes will be able to manage students and course information seamlessly. 
  2. Admin can send promotion emails about their courses and discounts to students who have made enquiries. 
  3. Admin will know how many students have made enquiries and for which course in particular duration of time. 
  4. Admin can analyze the information to know what courses are in demand. 
  5. Admin will be able to store and view the admission details like date of joining, course name into database and he will be able to also view the payments information. 
Advantages of Training Institute Management System - 
  1. Admin can not access the system from internet. 
  2. Admin can not send sms to students regarding fee dues etc. 
Sample Forms and Reports of the Project

Admission Details Form

Admission Details Report


Students Enquiry Details
Student Enquiry Reports
Training Institute Management System - Source Code in VB6
If you need full source code of this project, you can mail me at reply2sagar@gmail.com. Many students in final year from computer engineering, diploma in IT, MCA, BCA, MCS, BCS, MCM, BCM branches have found this project related to job system very useful. If you need a final year project in any other technology or domains as mentioned below you can reach me at reply2sagar@gmail.com

I have final year projects in below technologies.
  1. C#.Net 
  2. Asp.Net  - IIS
  3. Java - JSP, Tomcat
  4. PHP
  5. VB.Net
  6. VB6
I have final year projects in below domains/Business areas.
  1. Hospital Management system
  2. Online Book Shopping Site
  3. Hotel Management system
  4. Online Hotel Booking system
  5. Training institute management system
  6. Web application testing using selenium
  7. Blood Bank management system
  8. Recruitment management system
  9. College Management System
  10. Online Admission System
  11. Inventory Management System
  12. School Database Management System
  13. Any Online Shopping Website
What do you think on this topic? Please express your opinion through comment below. You can reach me at reply2sagar@gmail.com

Wednesday 5 February 2014

Ms access provider not displaying in ODBC manager in windows 7 64-bit OS

Problem

When we try to create a DSN in windows 7 with 64 bit, the drivers for the microsoft access is not visible.
Only sql server drivers are displayed.


Solution

To solve this issue you must launch the ODBC driver dialog window using below exe file.
c:\windows\sysWOW64\odbcad32.exe

When you open the ODBC manager from above exe file, all 32-bit drivers are displayed including ms-acess (.mdb and .accdb ) and you can create a dsn for access database.


What do you think on this topic? Please express your opinion through comment below

Appu ghar in Pimpri Chinchwad

Appu ghar is a famous amusement park located at nigdi pradhikaran in Pimpri Chinchwad.
You can spend a quality time with your family especially kids during evening.

Major Attractions in Appu Ghar are roller coaster, my fair lady and columbus ride.

Roller Coster Ride in Appu Ghar
After you enter the main gate, you will have to park your vehicles.There is lot of space for car and bike parking. You will have to buy tickets to enter the appu ghar. When I visited, I had to pay Rs. 30 per person. This is just an entry fee. You will have to buy tickets for each ride inside the park separately.

One of the rides for kids

Appu Express Ride in Appu Ghar
Appu Express is a small train ride which runs through the park.
Gammat Firki Ride in Appu Ghar
A Kid enjoying the helicopter ride in Appu ghar.
Ganesh Temple in Appu Ghar
There are 2-3 good restaurants inside the park where you can enjoy the food. They are bit costly.

Beautiful scene inside the park.
There various kinds of the trees and flowers inside park as well.

Giza pyramid in the Appu Ghar

Columbus ride in appu ghar
My fair Lady ride in appu ghar
Plane ride in Appu Ghar
I had a good time pass inside appu ghar. When are you planning to visit it?


What do you think on this topic? Please express your opinion through comment below

Sponsored Links

Popular Posts

Comments

ShareThis