Remove “Server” header from ASP.NET Core 2.1 application

This solution works on IIS 10+ version and allows to remove x-powered-by and server headers in server response. In IIS 10 a new attribute was added: removeServerHeader. We need to create web.config file in asp.net core application with following content: <?xml version=”1.0″ encoding=”utf-8″?> <configuration> <system.webServer> <security> <requestFiltering removeServerHeader=”true” /> </security> <httpProtocol> <customHeaders> <remove name=”X-Powered-By” /> … Read more

How to configure ASP.net Core server routing for multiple SPAs hosted with SpaServices

Thanks to SteveSandersonMS and chris5287 over on Github for pointing me towards the solution on this. IApplicationBuilder.Map can segregate paths into different areas of concern. If you wrap a call to app.UseSpa in a call to app.Map, the SPA will be handled only for the path specified by the Map call. The app.UseSpa call ends … Read more

Unauthorized nuget package from Visual Studio Team Services using asp.net core rc2

I know that it’s not exactly the same issue, but people may come across this one alongside as I did. I have installed VS Community 2019​ and yesterday I decided to remove the VS 2017, but after that, when I tried to restore the Nuget Packages made by the company, it started displaying an error … Read more

What is the advantage of using Tag Helpers in ASP.NET Core MVC

The most important improvement I’ve seen so far is the control it guarantees over your HTML elements. While convenient, the Html helpers used by MVC create problems when you try to do things they weren’t built for. A simple example can be seen when using the TextBox in MVC5: @Html.TextBoxFor(m => p.Name) The resulting HTML … Read more

Derived type’s properties missing in JSON response from ASP.NET Core API

While the other answers are good and solves the problem, if all you want is the general behavior to be like pre netcore3, you can use the Microsoft.AspNetCore.Mvc.NewtonsoftJson NuGet package and in Startup.cs do: services.AddControllers().AddNewtonsoftJson() More info here. This way, you don’t need to create any extra json-converters.

.NET Core locking files

This may also help when running your aspnetcore app in IIS. Add the following to your csproj: <Target Name=”PreBuild” BeforeTargets=”PreBuildEvent”> <Exec Command=”echo &quot;App Offline&quot; /a &gt; &quot;$(ProjectDir)app_offline.htm&quot;” /> </Target> <Target Name=”PostBuild” AfterTargets=”PostBuildEvent”> <Exec Command=”del &quot;$(ProjectDir)app_offline.htm&quot;” /> </Target>

How inject service in AutoMapper profile class

To solve your problem you just need to wire IUserManager in DI, and make sure UserProfile dependency is resolved. public void ConfigureServices(IServiceCollection services) { // … services.AddSingleton<IUserManager, UserManager>(); services.AddSingleton(provider => new MapperConfiguration(cfg => { cfg.AddProfile(new UserProfile(provider.GetService<IUserManager>())); }).CreateMapper()); } And having that said, I would probably try to keep single responsibility per class, and not have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)