Tuesday 25 July 2023

web api

 "ConnectionStrings": {

    "connection": "data source = DESKTOP-B8SJS28; initial catalog = test7523; trusted_connection = true; TrustServerCertificate=true"

  },





 var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: false);

            IConfiguration configuration = builder.Build();

            string constring = configuration.GetValue<string>("ConnectionStrings:connection");

            string kk = "";


            using (SqlConnection con = new SqlConnection(constring))

            {

                con.Open();

                SqlCommand cmd = new SqlCommand("get_record", con);

                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                

                da.Fill(dt);

                con.Close();

               

                kk = JsonConvert.SerializeObject(dt);


                //var response = Request.CreateResponse(HttpStatusCode.OK);

                //response.Content = new StringContent(kk, System.Text.Encoding.UTF8, "application/json");

            }

            return kk; 


"Data Source=SQL8005.site4now.net;Initial Catalog=db_a96a36_test;User Id=db_a96a36_test_admin;Password=AKas@#123"


Wednesday 19 July 2023

link

 https://github.com/akash121212/Practise

Test

 

  1. using Microsoft.IdentityModel.Protocols;  
  2. using Microsoft.IdentityModel.Protocols.OpenIdConnect;  
  3. using Microsoft.IdentityModel.Tokens;  
  4. using System;  
  5. using System.Collections.Generic;  
  6. using System.Configuration;  
  7. using System.Globalization;  
  8. using System.IdentityModel.Tokens.Jwt;  
  9. using System.Linq;  
  10. using System.Linq.Expressions;  
  11. using System.Text;  
  12. using System.Threading.Tasks;  
  13.   
  14.   
  15.   
  16. namespace AzureADTokenValidation  
  17. {  
  18.     class Program  
  19.     {  
  20.         static async Task Main(string[] args)  
  21.         {  
  22.             string token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IkN0VHVoTUptRDVNN0RMZHpEMnYyeDNRS1NSWSJ9.eyJhdWQiOiI3YjFjZTFhZC1hZjE1LTRlNWYtOWFlNC1hYWYwYTY4YTdhYjQiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3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aEfA";  
  23.             string myTenant = "e8e6d018-a834-406b-9f43-2e94ae425876";  
  24.             var myAudience = "7b1ce1ad-af15-4e5f-9ae4-aaf0a68a7ab4";  
  25.             var myIssuer = String.Format(CultureInfo.InvariantCulture, "https://login.microsoftonline.com/{0}/v2.0", myTenant);  
  26.             var mySecret = "t.GDqjoBYBhB.tRC@lbq1GdslFjk8=57";  
  27.             var mySecurityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(mySecret));              
  28.             var stsDiscoveryEndpoint = String.Format(CultureInfo.InvariantCulture, "https://login.microsoftonline.com/{0}/.well-known/openid-configuration", myTenant);  
  29.             var configManager = new ConfigurationManager<OpenIdConnectConfiguration>(stsDiscoveryEndpoint, new OpenIdConnectConfigurationRetriever());  
  30.             var config = await configManager.GetConfigurationAsync();  
  31.   
  32.             var tokenHandler = new JwtSecurityTokenHandler();  
  33.   
  34.             var validationParameters = new TokenValidationParameters  
  35.             {  
  36.                 ValidAudience = myAudience,  
  37.                 ValidIssuer = myIssuer,  
  38.                 IssuerSigningKeys = config.SigningKeys,  
  39.                 ValidateLifetime = false,  
  40.                 IssuerSigningKey = mySecurityKey  
  41.             };  
  42.   
  43.             var validatedToken = (SecurityToken)new JwtSecurityToken();  
  44.   
  45.             // Throws an Exception as the token is invalid (expired, invalid-formatted, etc.)  
  46.             tokenHandler.ValidateToken(token, validationParameters, out validatedToken);  
  47.             Console.WriteLine(validatedToken);  
  48.             Console.ReadLine();  
  49.         }  
  50.     }  
  51. }  

Saturday 11 July 2020

Variables in Php

                                         Variables

Variables are use to Store the value like Numeric,Characters,Strings.

We can say that "Variables is like a container . Which is store the Value.or Hold The Value"

Php Variables are Start With "$" Sign.

Some Important Things For Variables in Php 

We can create variables like that:

$ABC, $Abc, $abc, $_abc, $a_bc, $abc_1 

we can't create variable like that:
$12abc , $ abc

Example

<?php


     $a =1;
    $b=2;
    $c=$a+$b;
    echo $c;
  
?>

Comments in Php

                             Comments

Comments is not Execute in Php. It is part That new Developer can read it and Understand the Code.
Comment section Text Never Show On Browser During Execution.

There are Two Types of Php Comments :

1.  Single-Line Comments.
2. Multiple-Line Comments.

                                       Single Line Comments


<?php

// This is Single-Line Comments.
# This is Single-Line Comments.
echo "Hello World";


?>

By using Single-Line Comment We can Comment a single Statement.



                                          Multiple-Line Comments



<?php

/*
statement-1
statement-2
statement-3
.
..
.
.
*/
echo "Hello World";


?>

By using Multiple-Line Comment We can Comment Multiple Statement.