How to connect ASP.Net Core to a SQL Server Docker container on Mac

I know that @MikePR ‘s comment serves as the answer, but I wanted to provide a more complete answer for the issue I had. I could not get dotnet ef database commands to execute evan after using the connection string with Trusted_Connection=false. With the help of this article, I was able to use this connection … Read more

Submitting a razor form using JQuery AJAX in MVC6 using the built-in functionality

Ajax works the same way, but instead of the @Ajax helper’s, use the new MVC 6 Tag Helpers (don’t forget to reference ‘jquery’ and ‘jquery.unobtrusive-ajax’ scripts). JQuery Unobtrusive Ajax exists in the Asp.Net GitHub repo and can be Bower pulled. Using the new MVC TagHelpers, you simply declare the form like the following: <form asp-controller=”Home” … Read more

Required query string parameter in ASP.NET Core

In ASP.NET Core 2.1 and above you can use top level parameters validation. You can put attributes on parameters [HttpGet] public IActionResult GetDices([BindRequired, Range(1, 6)]int number) { if (!ModelState.IsValid) { return BadRequest(“Invalid number”); } return Ok(_diceRepo.GetDices(number)); } More about this https://programmingcsharp.com/asp-net-parameter-validation/#Top-level_node_validation

What does `HTTPContext.SignInAsync` do behind the scenes?

Note that the code has been changed, below is for version active in 2017 when the question was asked. https://www.nuget.org/packages/Microsoft.AspNetCore.Http.Abstractions/ https://github.com/aspnet/HttpAbstractions New github link: https://github.com/dotnet/aspnetcore This is a start, from here you can follow the code depending on what you want to know. Default AuthenticationService in Microsoft.AspNetCore.Authentication public virtual async Task SignInAsync(HttpContext context, string scheme, … Read more

Local user account store for Web API in ASP.NET Core 2.0

Try start your project in the console with the command dotnet new webapi -au Individual You can open your project in VS after that. (to work around the dialog). Then you can use for example the authorize-attribute. But the project is still configured to use Azure Bearer Authentication. You have to decide where to get … Read more

Is ViewData the new standard over ViewBag for ASP.Net 5 (core)?

Both are still valid. There is no specific guidance on the docs.asp.net github project. Although there is this discussion on docs.asp.net issues. That links through to a comment from one the product team which says: “Since ViewData (Dictionary) look-ups far out-perform ViewBag (dynamic) invocations, the last is probably the best choice.” So I’d say it … Read more

Handling exception in asp.net core?

You can use to handle exceptions UseExceptionHandler(), put this code in your Startup.cs. UseExceptionHandler can be used to handle exceptions globally. You can get all the details of exception object like Stack Trace, Inner exception and others. And then you can show them on screen. Here Here You can read more about this diagnostic middleware … Read more

MediatR publish and MediatR send

MediatR has two kinds of messages it dispatches: Request/response messages, dispatched to a single handler Notification messages, dispatched to multiple handlers Send may return a response, but do not have to do it. Publish never return the result. You are sending requests (sometimes called commands) by _mediator.Send({command}) to exactly one concrete handler. It may be … Read more

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