Amazon Ad

Saturday 13 December 2014

Angular JS in ASP.NET

Hi,

I was creating one simple form and code in Angular.js. It was my first day of working with Angular.js. Following is the code to start with

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Angular Forms</title>
    <link href="Content/bootstrap.min.css" rel="stylesheet" />
    <script src="Scripts/angular.js"></script>
</head>

Friday 28 November 2014

Send Email To Any Email From Any Email

Hi Guys,

Following is the code for sending email to any user from any user. The below code is a good code and please do not misuse this.      

 MailMessage objMail = new MailMessage();
    //Replace email_of_the_user with the email whom you want to send to
            objMail.To.Add("email_of_the_user");
    //Replace email_to_be_cc'ed with the email whom you want to cc to
            objMail.CC.Add("email_to_be_cc'ed");
    //Replace Your_Email_ID with email id from whom you want the email to be sent from
            objMail.From = new MailAddress("Your_Email_ID", "Alias Name");

    //Subject of the email
            objMail.Subject = "Subject for the email";

            StringBuilder emailbody = new StringBuilder();
            emailbody.Append("Dear User,<br/><br/>");
            emailbody.Append("This is a test email <br/>");
            emailbody.Append("<br/><br/>Thanks<br/><b>Division of Infotech</b>");
            objMail.Body = emailbody.ToString();
            objMail.Priority = MailPriority.High;
            objMail.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Timeout = 600000;
        //Replace EmailID with Email Id from where you want the email to be sent to
        //Replace Password with the email(email from) password
            smtp.Credentials = new System.Net.NetworkCredential("EmailID", "Password");
            smtp.EnableSsl = true;
            smtp.Send(objMail);
            objMail.Dispose();

Thanks
Ritesh

Wednesday 26 November 2014

Find Local and Internet IP Address in C#

Hi Guys,

I was given a task to get the IP Address of a computer. Most of the times when we are working we have two IP's one assigned on the LAN network and one assigned by the internet ISP. I was given a task to find both of them. Here is how i was able to create the same.

    //For ISP (Internet Service Provider) IP Address
    public static string GetIPAddress()
        {
            System.Web.HttpContext context = System.Web.HttpContext.Current;
            string sIPAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(sIPAddress))
            {
                return context.Request.ServerVariables["REMOTE_ADDR"];
            }
            else
            {
                string[] ipArray = sIPAddress.Split(new Char[] { ',' });
                return ipArray[0];
            }
        }

    //For LAN (Local Area Network) IP Address
        public string LocalIPAddress()
        {
            IPHostEntry host;
            string localIP = "";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    localIP = ip.ToString();
                    break;
                }
            }
            return localIP;
        }

Thanks
Ritesh Tandon

Generate Password As Per Password Policy in C#

Hi Guys,

I was given a task to generate a password having following conditions

1. Min 10 Chracters
2. Must have one upper case letters
3. Must have one or more lower case letters
4. Must have one or more special characters
5. Must have one or more numbers.

Following is how i was able to do the same in C#

private string ActionNewPassword()
    {
        String Num = "0123456789";
        String Sp = "!@#$%&*()+{}[]^-";
        String SL = "abcdefghijklmnopqrstuvwxyz";
        String UCL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random rnd = new Random();
       
        //One or more upper case letters
        string part1 = UCL.Substring(rnd.Next(UCL.Length),1);

        //One or more numbers
        string part2 = Num.Substring(rnd.Next(Num.Length), 1);

        //Minimum 4 small case letters
        string part3 = "";
        for(int i=0;i<4;i++)
            part3 += SL.Substring(rnd.Next(SL.Length), 1);

        //Minimum 1 special character
        string part4 = Sp.Substring(rnd.Next(Sp.Length), 1);

        //Minimum 3 small numbers
        string part5 = "";
        for (int i = 0; i < 3; i++)
            part5 += SL.Substring(rnd.Next(SL.Length), 1);

        string pwd = part1 + part2+part3+part4+part5;

        //Message.InnerHtml = pwd;
       
        return pwd;
    }

Thanks
Ritesh Tandon

Generate Verification Code In MS SQL

Hi Guys,

I was given a task to generate an email verification code from MS SQL. I finally achieved with some  string functions and inbuilt Random function in MS SQL. Here is the code

    --Generate verification code
    declare @ab varchar(36)='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    declare @vercode varchar(11)=''
    declare @counter int=0
    declare @ind int=0
    WHILE @counter < 9
    BEGIN
        set @ind=(select RAND()*35)
        set @vercode=@vercode+(select SUBSTRING(@ab, @ind+1, 1))
        SET @counter = @counter + 1
    END
    print @vercode

The below code generates an alphanumeric code having 9 alphanumeric characters. You can increase or decrease the length by chaning the lenght of the @vercode variable and the while loop counter.

Thanks
Ritesh

Friday 29 August 2014

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Invalid access to memory location. (Exception from HRESULT: 0x800703E6)

Dear all,

I was struggling with an error in ASP.NET. The error was coming when i implemented Ad (Active Directory) password change code in one of my forms. It some times worked but sometimes it gave the following error

 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: Invalid access to memory location. (Exception from HRESULT: 0x800703E6) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) at _adPassword.ChangeUserADPassword(String Username, String Password, String newPwd)

I searched a lot and then found a solution for this problem. The problem was the CPU overload on the server. The server CPU usage when moved above 75-90% this form resulted this error. I recycled the Application pool and also made some changes on the server to maintain the CPU usage below 75%. This solved the problem and now i don't face any sort of problem with this form.

Thanks
Ritesh Tandon

Saturday 12 July 2014

Creating Fault Injections For ASP.NET MVC Web API

Hi Guys,

I was working on a new project which was having a challenge to create fault injection in a running Web API.

Step 1 : Create a model Class name "User"

public class User
    {
        public int Id { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Gender { get; set; }
    }


Wednesday 9 July 2014

Merge Git Branch

Hi guys,

Today i am going to tell you the commands to merge your branch with your live branch. Assuming that you have two branches a. Test b. Live. Where Test branch has all the development files where as "Live" branch has the data of the live website. Here is how we can merge these two branches.

1. git pull origin test
2. git checkout live (in case the branch is not in local rep. then use git checkout -b live)
3. git branch (To check which branch is current branch. The live branch will be your current branch)
4. git add .
5. git commit -m "message"
6. git status
7. git merge test (Merge the live branch with test branch)
8. git pull origin live
9. git push origin live
10. git pull origin live

In case you want to pull all the live contents on to your local repository :
git reset --hard origin/test
This tells it to fetch the commits from the remote repository, and position your working copy to the tip of its master branch. The above command will replace all the local files from "test" branch with all the files on the Github remote branch "test".

Thanks
Ritesh

Thursday 3 July 2014

Selectize.js Dependent Dropdowns For Country And City

Hi Guys,

I was working with selectize.js and a problem occurred when i was using select/dropdown list, I was working in PhP. Here is the code for country dropdown which successfully loads city on selecting country from country dropdown.

<div class="form-group mb10">

        <div class="row">

            <div class="col-sm-6 mb5">

                <label class="control-label">Country</label>

                <div class="has-icon pull-right">

                    <?php echo CHtml::dropDownList('ClientProjects[country]','',CHtml::listData(States::model()->findAll(array('order'=>'name ASC')),'id', 'name'),array('class'=>"form-control pr10",'prompt' =>'Select Country','id'=>"country",'ajax'=>array(

'type'=>'POST',

'url' => CController::createUrl('/globaldata/getCity'),

'data'=> array('country'=>'js:this.value'),

'success'=>'function(data){loadcity1(data);}'

)

));?>

                 </div>

            </div>

How to avoid reentering of github user and password when pull or push

Hi Guys,

I was facing a problem when i was working on a project on github. The pull and push git commands were asking me my github username and password when i pushed or pulled the branch. Following are the steps :

Step 1 : Remove the already added origin if any by using this command

>git remote rm origin

Step 2 : Now we will add an origin with username and password, This will get stored in the git file and won't ask the username and password again.

>git remote add origin https://username:password@github.com/organizationname/repositorypath

where username is your github user name and password is the password of your github user. In case you cannot find the organizationname and repositorypath, You can find this by copying the https clone URL of the repository. i.e incase your your URL is "https://github.com/riteshtandon23/MyCodio.git" having username as "test" and password as "test123" then your git command will be


>git remote add origin https://test:test123@github.com/riteshtandon23/MyCodio.git

Step 3 : Give a command to pull the branch on local

>git pull origin master

It won't ask you any login or password same will happen with the push command.

> git push origin master

Hope it helped you.a

Thanks
Ritesh

Monday 26 May 2014

jQuery ajax POST and saving value in local javascript variable


Hi Guys,

I was working on an ASP.NET page and found a strange problem. Whenever i
was calling the jquery ajax POST request, The data from webservice was
available in the success function but not after $.ajax request code. This
was strange i as wanted to access the data after calling the ajax POST
request.

Here is the problem

var localdata;
$.ajax({
data:"{'id':'1'}",
type:"POST",
dataType:"json",
contentType:"application/json",
url:"http://www.test.com/test.svc/HelloWorld",
success:function(data){localdata=data;alert("Inside Success "+localdata);},
error:function(a,b,c){}
});
alert("After ajax "+localdata);

After executing the above it gave me "Inside Success Hello", But the second
alert message gave me "After ajax undefined". This was due to the fact
that the first call was made inside success which was asynchronous, Whereas
the second alert was not asynchronous and didn't wait until the
$.ajax POST request executed.

To solve the same, I made it synchronous as i had to store the result of
webservice in a local variable, Here is the code

var localdata;
$.ajax({
data:"{'id':'1'}",
type:"POST",
dataType:"json",
        async:false, //setting this made it a synchronous call
contentType:"application/json",
url:"http://www.test.com/test.svc/HelloWorld",
success:function(data){localdata=data;alert("Inside Success "+localdata);},
error:function(a,b,c){}
});
alert("After ajax "+localdata);

Thanks
Ritesh Tandon

Thursday 1 May 2014

Creating Asynchronous Thread in Global.asax in MVC

Hi guys,

I was facing a problem of creating asynchronous thread in Global.asax in MVC. I was able to create a thread which runs asynchrounsly without affecting the application. Here is how how i did it in global.asax.cs file. It also requires two namespaces 1. System.Threading 2. System.Threading.Tasks, Please do add them.

Step 1: Create a async Task, here in this example its MyThread.

private async Task<int> MyThread()
        {
            while (true)
            {
                string result = await Operations();
                await Task.Delay(5000);
            }
            return 1;
        }

Step 2: Create another async Task performing all the operations.

public async Task<String> Operations()
        {
            return "Hello";
        }
Step 3: Inside Application_Start call the thread.

protected async void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            AllSync();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }

Thanks
Ritesh Tandon

Monday 21 April 2014

Creating Dependent DropDownList in MVC without jQuery.



Hi Guys,

I was given a task to generate dependent values in DropDownList without using jQuery. However this approach is not recommended but incase you still want to generate the dependent dropdownlist values based upon the parent dropdownlist value, Here are the steps to do so.

In my example i am using an example of Category, SubCategory and Product. Based on the category dropdown, subcategory dropdown list is generated and the product is then saved based on the category and subcategory values. In this example i have taken both category and subcategory reference in product table, However it can be done by taking only reference of subcategory table.

Step 1: Generate models
public class Category
    {
        [Key]
        public virtual int CategoryId { get; set; }
        public virtual string CategoryName { get; set; }
        public List<SubCategory> SubCategories { get; set; }
        public List<Product> Products { get; set; }
    }

Wednesday 16 April 2014

How to get client's MAC Address from browser


Hi Guys,

I was having problem of finding out MAC address from browser. I finally achieved the same by using help from a blog and jQuery. The current code is tested on local LAN and it gives the MAC address based on the local LAN ip address.

Here is how i achieved it


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

Friday 14 February 2014

How To Create YouTube like website.

Hi Guys,

I recently used OpenTok API for my website to record videos and play videos. My requirement was met where users were able to record a video and play the same video in future without storing it on my server. This way i saved server space and bandwidth utilization of my server.

Here is the code

Wednesday 5 February 2014

Get Browser and Operating System from the user agent stored in MySql database.

Here is how to get Browser and Operating System from the user agent stored in MySql database.

select 
user_agent,
CASE
WHEN user_agent REGEXP 'MSIE [[:alnum:]]+.[[:alnum:]]+' THEN SUBSTRING(user_agent, LOCATE('MSIE ', user_agent), LOCATE(';', user_agent, LOCATE('MSIE ', user_agent))-LOCATE('MSIE ', user_agent))
WHEN user_agent REGEXP 'Firefox/[[:alnum:]]+.[[:alnum:]]+' THEN SUBSTRING(user_agent, LOCATE('Firefox/', user_agent))
WHEN user_agent REGEXP 'Chrome/[[:alnum:]]+.[[:alnum:]]+' THEN SUBSTRING(user_agent, LOCATE('Chrome/', user_agent))
WHEN user_agent REGEXP 'Safari/[[:alnum:]]+.[[:alnum:]]+' THEN SUBSTRING(user_agent, LOCATE('Safari/', user_agent))
WHEN user_agent REGEXP 'SeaMonkey/[[:alnum:]]+.[[:alnum:]]+' THEN SUBSTRING(user_agent, LOCATE('SeaMonkey/', user_agent))
WHEN user_agent REGEXP 'Opera/[[:alnum:]]+.[[:alnum:]]+ ' THEN SUBSTRING(user_agent, LOCATE('Opera/', user_agent), LOCATE(' ', user_agent, LOCATE('Opera/', user_agent))-LOCATE('Opera/', user_agent))
WHEN user_agent REGEXP 'Dolfin/[[:alnum:]]+.[[:alnum:]]+ ' THEN SUBSTRING(user_agent, LOCATE('Dolfin/', user_agent), LOCATE(' ', user_agent, LOCATE('Dolfin/', user_agent))-LOCATE('Dolfin/', user_agent))
WHEN user_agent REGEXP 'AppleWebkit/[[:alnum:]]+.[[:alnum:]]+ ' THEN SUBSTRING(user_agent, LOCATE('AppleWebkit/', user_agent), LOCATE(' ', user_agent, LOCATE('AppleWebkit/', user_agent))-LOCATE('AppleWebkit/', user_agent))
ELSE 'Unknown'
END AS BROWSER,
case 
when instr(user_agent,'compatible')>0 && instr(user_agent,';')>0 && instr(user_agent,'Windows')>0 then CONCAT('Windows',(substring_index(substring_index(user_agent,'; Windows',-1),';',1))) 
when instr(user_agent,';')>0 && right(user_agent,1)!=')' then trim(substring_index(substring_index(user_agent,';',1),'(',-1)) 
when instr(user_agent,';')=0 && right(user_agent,1)=')' then substring_index(substring_index(user_agent,')',1),'(',-1) 
when right(user_agent,1)=')' then trim(substring_index(substring_index(user_agent,';',1),'(',-1)) 
else trim(substring_index(substring_index(user_agent,')',1),'(',-1)) end as 'OS'
from browsers
/*Fetch all records where user_agent is not null*/
where user_agent is not null 
/*Fetch those records whose user_agent is available*/
and instr(user_agent,'Mozilla/5.0')>0 
/*Exclude Google bots and other bots*/
and instr(user_agent,'http')=0

Thursday 30 January 2014

Authorise Your User From StackOverFlow

Hi Guys!!,

Today i am going to tell you how to validate your user from StackOverFlow API, After tonns of effort i have developed this code.
You can use this code to authenticate your user from Stackoverflow and it also give you the relevant user details.But you need to create an app
in stackexchange.com website which will provide you a clientid and key.

Here is the code


Wednesday 22 January 2014

How to create a GitHub Hook to update my website from GitHub Push.



Step 1 Generate a ssh key on the server and copy that ssh keys into the .ssh\id_rsa file. Also add the public key in file id_rsa.pub into your github repository under settings and ssh keys.

Step 2 On the server install git.

Step 3 On the github make sure you have a repository and create a branch named "development".

Step 4 Push all your project files onto your repository and in "development" branch.

Step 5 Pull the files from the github respository into your server's folder. Also make sure that you have sufficient rights for this folder i.e IUSR user should have sufficient rights.


Saturday 18 January 2014

Get Deatils of Git user from Web API.


Hi Guys,

Today i am going to tell you how you can get the Git user details in Wep API.

Step 1. Go to global .asax file and add the following lines after the built in class i.e it should look like

namespace TestGit
{

    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<TestGitContext, MyConfiguration>());
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }
    }
    public class MyConfiguration : System.Data.Entity.Migrations.DbMigrationsConfiguration<TestGitContext>
    {
        public MyConfiguration()
        {
            this.AutomaticMigrationsEnabled = true;
        }
    }
}

Step 2: In App_start folder open the file WebApiConfig.cs and add the following lines after routes i.e it should look like

    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);

            config.Routes.MapHttpRoute(
                name: "DefaultApi1",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );


            var json = config.Formatters.JsonFormatter;
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

        }
    }

Step 3: Create a model class User, i.e

public class User
    {
        [Key]
        public int Id {get;set;}
        public string UserName { get; set; }
        public string Email { get; set; }
        public string Name { get; set; }
        public string Country { get; set; }
        public string Location { get; set; }
        public string Photo { get; set; }
        public string Languages { get; set; }
        public bool IsAvailableForHiring { get; set; }
    }

Step 4: Create a web api controller using the model class "User" and add a get action, It should look like

 [ActionName("GetUser")]
        // GET api/CodeVitae/5
        public User GetUser(string id)
        {

            id = RemoveSpecialCharacters(id);
            //User user = db.Users.Find(id);
            User user = (from u in db.Users where u.UserName == id select u).FirstOrDefault();
            if (user == null)
            {
                ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
                //throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
                string url = "https://api.github.com/users/" + id + "?client_id=xxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxx";
                WebResponse webResponse = GetAPIData(url);
                User u=ReadFrom(webResponse,false);
                url = "https://api.github.com/users/" + id + "/repos" + "?client_id=xxxxxxxxx&client_secret=xxxxxxxxxx";
                WebResponse webResponse1 = GetAPIData(url);
                User u1 = ReadFrom(webResponse1,true);
                u.Languages = u1.Languages;
                db.Users.Add(u);
                db.SaveChanges();
                user = u;
            }

            return user;
        }

        public static string RemoveSpecialCharacters(string str)
        {
            StringBuilder sb = new StringBuilder();
            foreach (char c in str)
            {
                if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '-' || c == '_')
                {
                    sb.Append(c);
                }
            }
            return sb.ToString();
        }

        public User ReadFrom(WebResponse twitpicResponse,bool isMultiple)
        {
            User newUser = new User();
            using (var reader = new StreamReader(twitpicResponse.GetResponseStream()))
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                var objects = js.Deserialize<dynamic>(reader.ReadToEnd());
                String languages = "";
                foreach (var o in objects)
                {
                    if (isMultiple)
                    {
                        try
                        {
                            foreach (var g in o)
                            {
                                if (g.Key != null)
                                {
                                    if (g.Key == "language")
                                    {
                                        if (g.Value != null)
                                        {

                                              string t = g.Value;
                                              Technology tech = (from u in db.Technologies where u.Name == t select u).FirstOrDefault();
                                              if (tech == null)
                                              {
                                                  Technology te= new Technology();
                                                  te.Name = t;
                                                  db.Technologies.Add(te);
                                              }
                                                  if (!(languages.Contains(g.Value)))
                                                      languages = (string.IsNullOrEmpty(languages)) ? g.Value : languages + "," + g.Value;
                                             
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    else
                    {
                        //Console.WriteLine(o["title"]);
                        if (o.Key == "login")
                        {
                            if (o.Value != null)
                                newUser.UserName = o.Value;
                        }
                        else if (o.Key == "name")
                        {
                            if (o.Value != null)
                                newUser.Name = o.Value;
                        }
                        else if (o.Key == "location")
                        {
                            if (o.Value != null)
                                newUser.Location = o.Value;
                        }
                        else if (o.Key == "email")
                        {
                            if (o.Value != null)
                                newUser.Email = o.Value;
                        }
                        else if (o.Key == "avatar_url")
                        {
                            if (o.Value != null)
                                newUser.Photo = o.Value;
                        }
                        else if(o.Key=="hireable")
                        {
                            if (o.Value != null)
                                newUser.IsAvailableForHiring = o.Value;
                        }
                    }
                }
                newUser.Languages = languages;
            }
            return newUser;
        }

        public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }


Thats it folks enjoy!!

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:...