Pages

Sunday, April 12, 2020

Postman screen is blank or white or black

For Windows computers with certain GPU, Postman may display a blank/black window when opened, and elements in the app may not be rendering correctly or at all.

This issue may be related to a known issue where Postman doesn’t launch with certain GPU. A workaround for this issue involves disabling your GPU. Disabling GPU rendering for Postman generally allows the app to run successfully. To do so, you'll need to add a Windows environment variable: POSTMAN_DISABLE_GPU, with the value: true

Saturday, April 11, 2020

How to do migration from code to database in core web API

using EmployeeService.Model;
using Microsoft.EntityFrameworkCore;


namespace EmployeeService.Domain
{
    public class Connection:DbContext
    {

        public Connection(DbContextOptions opt):base(opt)
        {


        }

        public DbSet<Employee> Employee { get; set; }
    }
}

services.AddDbContext<Connection>(sp => sp.UseSqlServer("server=servername;database=database name;integrated security=true;USER ID= user;Password=password"));


https://www.entityframeworktutorial.net/efcore/entity-framework-core-migration.aspx

Wednesday, March 6, 2019

MVC Internal Architecture

MVC Internal Architecture or Request Pipe Line or Mvc Request Life Cycle


                               Route Table
                                   Routes
                                   Controller+Action
                                 RouteCollection
                                     |
                                    MapRoute---set default route

                                                                           ActionResult
  Browser----------------------------------------------MVC----controller+Action--view----MapRoute--RouteCollection--RouteConfig.cs
                                                       |
                                                       IIS

Tuesday, March 5, 2019

c# imp topics


                                   
             1. Architecture of C#
             2. compilation phase and execution phase of c#.
             3. Architecture of Assembly
             4. Architecture of CLR.
             5. Static Assembly and Shared Assembly.
             6. properties---****
             7. Indexer
             8. Reflection
             9. collection---*****
             10. Generics----*****
             11. Threading
             12. Exception Handling
             13. Garbage collection
             14. Extension Method
             15. conceopt of CTS(common type system/CLS(common language spectification).
             16. constructor chanining
             17. Delegate
                 1.) Asynchronous call)---Major Topics
                 2.) Anonymous call
                 3.) Lamda Exprssion.----Major Topics
                 4.) Multicast Delegate
            18. Interface and Abstract ----Major Topics   
     

           Major Keywords:.
       
        1. Dynamic
        2. Var
        3. out/ref
        4. volatile
        5. sealed class
        6. struct
        7. union
        8. new   
        9. virtual
        10. override

Token in Web API C#.Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using WebApplication27.Models;

namespace WebApplication27.Controllers
{
    public class EmployeeController : Controller
    {
        // GET: Employee
        public ActionResult Index()
        {
            HttpClient obj = new HttpClient();
            obj.BaseAddress = new Uri("http://localhost:64430/api/");
            obj.DefaultRequestHeaders.Clear();
            obj.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //Now Apply HttpVerbs
            IEnumerable<string> empList;
            HttpResponseMessage response = obj.GetAsync("employee").Result;
            empList = response.Content.ReadAsAsync<IEnumerable<string>>().Result;
            ViewBag.temp = empList;
            return View();
        }

        public ActionResult sendtoken()
        {


            using (var client = new HttpClient { BaseAddress = new Uri("http://localhost:64430/") })
            {
               //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var token = client.PostAsync("Token",
                    new FormUrlEncodedContent(new[]
                    {
                     new KeyValuePair<string,string>("grant_type","password"),
                     new KeyValuePair<string,string>("username","user"),
                     new KeyValuePair<string,string>("password","user")
                    })).Result.Content.ReadAsAsync<AuthenticationToken>().Result;

                client.DefaultRequestHeaders.Authorization =
                       new AuthenticationHeaderValue(token.token_type, token.access_token);

                Task<HttpResponseMessage> m = client.GetAsync("api/Account");
                Task<string> values = m.Result.Content.ReadAsStringAsync();
                ViewBag.temp = values.Result;
                return View();
            }
        }
    }
}