ScreenShot Download from Webbrowser with C#

This method;
It takes a screenshot of the page you are on.

private void DownloadScreenShotImage()
        {
            int width, height;
            width = webBrowser1.ClientRectangle.Width;
            height = webBrowser1.ClientRectangle.Height;
            using (Bitmap image = new Bitmap(width, height))
            {
                using (Graphics graphics = Graphics.FromImage(image))
                {
                    Point p, upperLeftSource, upperLeftDestination;
                    p = new Point(0, 0);
                    upperLeftSource = webBrowser1.PointToScreen(p);
                    upperLeftDestination = new Point(0, 0);
                    Size blockRegionSize = webBrowser1.ClientRectangle.Size;
                    graphics.CopyFromScreen(upperLeftSource, upperLeftDestination, blockRegionSize);
                }
                image.Save("d:\\Test.bmp");
            }
        }

Hell yeah!

Asp.net core https redirect ERR_TOO_MANY_REDIRECTS (on IIS)

Hi,

Your project after you deploy on IIS; when you want to do http to https redirect;
“ERR_TOO_MANY_REDIRECTS” brush up against.

For Solution add in startup.cs;

public void ConfigureServices(IServiceCollection services)
{
  services.Configure<ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders = ForwardedHeaders.XForwardedProto;
            });
  services.AddHttpsRedirection(opts => {
                opts.RedirectStatusCode = StatusCodes.Status301MovedPermanently;
                opts.HttpsPort = 443;
            });
}

and,

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
..
 app.UseHttpsRedirection();
..
}

Asp.Net Core Deploying ERR_TOO_MANY_REDIRECTS ERROR ON IIS

Hi everyone,

You made a asp.net core. Everyting is okey in local. But on IIS deploying there is a problem.

Solution:

 <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />

to

 <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />

Terminal Environment on windows (Unix comamands,Git,Fish,Autocomplete)

Bkz: https://github.com/jorgebucaran/awsm.fish

1- Install Windows terminal and Ubuntu 20.xx version download on windows store

2-Fish-shell install https://github.com/fish-shell/fish-shell

3-Oh-my-fish install https://github.com/oh-my-fish/oh-my-fish

4-Fisher install https://github.com/jorgebucaran/fisher

omf install bobthefish (themeinstall) 

https://github.com/oh-my-fish/oh-my-fish/blob/master/docs/Themes.md

5-Z install -(folder manager)

6-Fish manuel config, insert alias.

Create custom config file for Docker and Dotnet cli run on ubuntu terminal

nano ~/.config/fish/config.fish in
alias docker="docker.exe"
alias docker-compose="docker-compose.exe"
alias dotnet="dotnet.exe"
alias python="python.exe"
alias virtualenv="virtualenv.exe"
alias pip="pip.exe"
alias explorer="explorer.exe"

alias gg="git push"
alias gm="git commit -m"
alias gma="git commit -ma"
alias gp="git pull"
alias gpr="git pull --rabase"
alias gcb="git checkout -b"
alias gs="git status"
alias gl="git log --n 5"

set fish_greeting Go, go go..!

Then active fish config:

source ~/.config/fish/config.fish

Customize vscode theme, material-theme active.

How can set default open shell?

chsh -s /usr/bin/fish
If error; run "which fish"

open the default terminal for vscode below run:

wsl --list --all

wsl --setdefault Ubuntu-20.04

Finished.

PgAdmin Not Opening / 401 Unauthorized

This problem welding text/plain  parameter regedit on windows.

For Solution;

Step1:

Open Regedit.

Step2:

Go to  root = HKEY_CLASSES_ROOT\.js\Content Type

Step3:

Change value; text/plain to text/javascript

Step4:

Restart pgAdmin

By!

Trick: Sql Query Generate with Excel

="update myTable_auth_user inner join 1rs.auth_user on auth_user.id = myTable_auth_user.user_id set identification_number = '"&B2&"', phone='"&C2&"',bank_name='"&D2&"',iban_number='"&E2&"',address='"&F2&"',tax_number='"&H2&"',invoice_name='"&J8&"' where auth_user.email = '"&A2&"';"

Asp.Net Core and Cookies

Enable Cookies in Project for:

Startup.cs file in insert

And this using cookies for:
 string username = Request.Cookies["username"];
 string password = Request.Cookies["password"];

 

Asp.Net Core Session Not Working (Solution)

Startup.cs file in;

services.Configure<CookiePolicyOptions>(options =>
            {              
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

change to:
options.CheckConsentNeeded = context => false;

Kestrel Server Different Port with Run For Asp.Net Core (Nginx)

Create kestrel service:

nano /etc/systemd/system/kestrel-oguzhanabali.com.service
[Unit]
Description=Oguzhan ABALI Blog

[Service]
WorkingDirectory=/var/www/oguzhanabali.com
ExecStart=/usr/bin/dotnet /var/www/oguzhanabali.com/OguzhanAbali.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

Add the code below:

Environment=ASPNETCORE_URLS=http://localhost:5001

Asp.Net Core appsettings json get value in static class

Example appsettings:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Create MyConfig name class and;

using Microsoft.Extensions.Configuration;
static class ConfigurationManager
{
    public static IConfiguration AppSetting { get; }
    static ConfigurationManager()
    {
        AppSetting = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();
    }
}

Now you can use it like :

string value = ConfigurationManager.AppSetting["value_Key"];