Amazon Ad

Monday, 24 March 2014

Create In Browser Compiler For C#,Java,C,C++,Python, Ruby and many more using CodeMirror and IDEOne

Hi Folks!

I was given a task to create a website which can compile the code, the code can be c#,java,c,c++,ruby,python and other languages. I found a very good API(IDEONE), really simple to implement and gives fast result. I also used codemirror, which is a great code editor for different languages and provides real time environment like keyword recognition.

I built the same in asp.net, Please follow the steps.

Tuesday, 18 March 2014

MongoDB With ASP.NET

Hi Guys,

Today i am going tell you how to use MongoDB with ASP.NET

1. Create reference of MongoDB in c#

a. Download MongoDb from http://www.mongodb.org/downloads
b. Extract the zip file into c:\mongodb folder
c. Create another folder in c: drive with name "data"
d. Inside "data" folder create a new folder with name "db".
e. go to command prompt and execute the file c:\mongodb\mongod, this will run mongodb service.
f. run another command prompt window and execute c:\mongodb\mongo
g. Some commands
    i. show dbs (To show all the databases)
    ii. use [dbname] (to switch to the mentioned database) , This also creates a new database incase its not there when a collection(table) is created.
    iii. db.users.insert({name:"test",age:"32",department:"Computer"});
   The above command will create a table "users" in the database ([dbname]) name provided by the user.
    iv. db.users.findAll()
   The above command will show all the records in users table.

Wednesday, 5 March 2014

How To Pass List<> Into Web API WebMethod

Hi,

I was struggling with passing List<> type parameter in Web API webmethod. Here is how i was able to resovle it.

1. Here is my model class

public class Users
    {
        [Key]
        public int UserId { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

2. public List<Users> TestUsers([FromBody]List<Users> users)
        {
            try
            {
                return users;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

3. Here is my json which was passed using curl command, Here is the complete command

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d "[{\"Email\":\"test@test.com\",\"FirstName\":\"Ritesh\",\"LastName\":\"Tandon\",\"UserType\":\"Normal\"},{\"Email\":\"test12@test.com\",\"FirstName\":\"Vedansh\",\"LastName\":\"Tandon\",\"UserType\":\"FB\"}]" "http://localhost:3760/api/Users/TestUsers"

This is how i was able to pass List<> type object in Web API. You can also use HttpClient class for passing json array.

Thanks
Ritesh

How to implement Captcha v3 in ASP.NET

 I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...