I’m building a .NET Core MVC on the latest version 2.2. I have a problem when I make changes to the CSHTML file and refresh the page, my changes...
I need some help with the select tag helper in ASP.NET Core. I have a list of employees that I’m trying to bind to a select tag helper. My...
I’ve done this before with MVC5 using User.Identity.GetUserId() but that doesn’t seem to work here. The User.Identity doesn’t have the GetUserId() method. I am using Microsoft.AspNet.Identity. 20 Answers 20
Back in RC1, I would do this: [HttpPost] public IActionResult Post([FromBody]string something) { try{ // ... } catch(Exception e) { return new HttpStatusCodeResult((int)HttpStatusCode.InternalServerError); } } In RC2, there no...
Sending a form POST HTTP request (Content-Type: application/x-www-form-urlencoded) to the below controller results into a HTTP 415 Unsupported Media Type response. public class MyController : Controller { [HttpPost] public...
Not sure what am I missing here but I am not able to get the values from my appsettings.json in my .net core application. I have my appsettings.json as:...
In appsettings.json { "MyArray": [ "str1", "str2", "str3" ] } In Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddSingleton<IConfiguration>(Configuration); } In HomeController public class HomeController : Controller { private readonly...
How do I get the Development/Staging/production Hosting Environment in the ConfigureServices method in Startup? public void ConfigureServices(IServiceCollection services) { // Which environment are we running under? } The ConfigureServices...
Can you please let me know how to get client IP address in ASP.NET when using MVC 6. Request.ServerVariables...
I created an .NET Core MVC application and use Dependency Injection and Repository Pattern to inject a repository to my controller. However, I am getting an error: InvalidOperationException: Unable...