HTTP Error 500.30 – ASP.NET Core 5 app failed to start

There may be a few reasons behind the error which you can only identify by debugging. You can try to debug this error using the steps below: Navigate to the root directory of the application using CMD Run the application using the command dotnet run (yourApplicationName).dll If there are any errors, they should appear in … Read more

Storing production secrets in ASP.NET Core

In addition to use Azure App Service or docker containers, you can also securely store your app secrets in production using IDataProtector: App secrets are entered with running a -config switch of the application, for example: dotnet helloworld -config; In Program.Main, detects this switch to let user to enter the secrets and store in a … Read more

Is it possible to self-host an ASP.NET Core Application without IIS?

Is it possible to self-host an ASP.NET Core Application without IIS? Yes. In fact, all ASP.NET Core applications are self-hosted. Even in production, IIS/Nginx/Apache are a reverse proxy for the self-hosted application. In a reasonably standard Program.cs class, you can see the self-hosting. The IISIntegration is optional – it’s only necessary if you want to … Read more

Get Current User in a Blazor component

There are three possibilities for getting the user in a component (a page is a component): Inject IHttpContextAccessor and from it access HttpContext and then User; need to register IHttpContextAccessor in Startup.ConfigureServices, normally using AddHttpContextAccessor. Edit: according to the Microsoft docs you must not do this for security reasons. Inject an AuthenticationStateProvider property, call GetAuthenticationStateAsync … Read more

Configure cors to allow all subdomains using ASP.NET Core (Asp.net 5, MVC6, VNext)

This has now been implemented in version 2.0.0. In your ConfigureServices use the following: options.AddPolicy(“MyCorsPolicy”, builder => builder .SetIsOriginAllowedToAllowWildcardSubdomains() .WithOrigins(“https://*.mydomain.com”) .AllowAnyMethod() .AllowCredentials() .AllowAnyHeader() .Build() ); Also, don’t forget to call UseCors in your Configure call too: app.UseCors(“MyCorsPolicy”);

Create Custom HTML Helper in ASP.Net Core

For me I thought my HTML helpers weren’t working until I spotted that the extension method is now on IHtmlHelper not HtmlHelper. So for .net core: public static IHtmlContent CheckboxListFor<TModel>(this IHtmlHelper<TModel> html, Expression<Func<TModel, List<CheckboxListItem>>> expression) … Instead of for .net: public static HtmlString CheckboxListFor<TModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, List<CheckboxListItem>>> expression) … EDIT: I’ve also updated the … Read more

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