For solution;
Open your chrome hsts setting and delete all policy for locahost.
chrome://net-internals/#hsts

16 gönderi işaretli AspNet MVC/Core
For solution;
Open your chrome hsts setting and delete all policy for locahost.
chrome://net-internals/#hsts
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(); .. }
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" />
Enable Cookies in Project for:
Startup.cs file in insert
app.UseCookiePolicy();
New a cookie create for:
CookieOptions cookie = new CookieOptions(); cookie.Expires = DateTime.Now.AddYears(10); Response.Cookies.Append("username", username, cookie); Response.Cookies.Append("password", password, cookie);
string username = Request.Cookies["username"]; string password = Request.Cookies["password"];
Startup.cs file in;
services.Configure<CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; });
change to:
options.CheckConsentNeeded = context => false;
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
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"];
Selamlar,
Solutionunuzda “Helpers” adında bir folder oluşturduktan sonra HtmlHepers.cs adında bir class oluşturuyorsunuz ve bu class aşağıdaki kodlardan oluşuyor.
public static class HtmlHelpers { public static string ActivePage(this HtmlHelper helper, string controller, string action) { string classValue = ""; string currentController = helper.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(); string currentAction = helper.ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(); if (currentController == controller && currentAction == action) { classValue = "active"; } return classValue; } }
Sonrasında _layout türevi menüyü yazdığınız yerde class=”@Html.ActivePage(“Home”,”Index”)” ekliyorsunuz. Bu size active stringini döndürecek. classValue=”active” bunu eğer active classınız farklıysa değiştirebilirsiniz.
İyi çalışmalar herkese..
Asp.net webform uygulamasında async bir api call işlemi yapmaya çalışıyorsanız webformun async çalışmasını doğrulamalısınız.
Async=True
Orn: <%@ Page Title=”” Language=”C#” Async=”true” MasterPageFile=”~/Mast.. gibi
Daha sonra HttpClient ile post yaptığınız yerde ConfigureAwait(false) demelisiniz.
Orn: HttpResponseMessage response = await client.PostAsJsonAsync(“api/user”, userDTO).ConfigureAwait(false); gibi.
Solution:
HttpResponseMessage response = await client.PostAsJsonAsync("api/user", userDTO).ConfigureAwait(false);
Bir daha ki ipucunda görüşmek üzere, İyi çalışmalar…