Category: ASP.NET
-
Unable to find the target operating system for the project
Hi everyone, I ran into the following error today after updating visual studio 2019 to version 16.6: unable to find the target operating system for the project I tried a fair few things to get this going again and I’m assuming they’re not all necessary, but I’ll list them just in case: – Clean solution…
-
View Raw SQL in EF Core – Simple Option
Hi everyone, I’ve been looking for a simple way of viewing the raw output of sql in my local environment without having to make code changes and came across the following config setup: { “Logging”: { “LogLevel”: { “Default”: “Debug”, “System”: “Information”, “Microsoft”: “Information” } } This will show the sql statements in your output…
-
Dynamic Robots.txt with Web Api 2
Hi everyone, For a project I’m currently working on I needed a dynamic robots.txt. Because our test environment is public facing we want to keep it from being indexed by Google etc. It took a bit of Googling to find a solution that worked, but in the end it was actually pretty simple. Here’s the…
-
LINQ to Entities does not recognize the method ‘System.Linq.IQueryable
Hi everyone, I ran into the following error today while attempting to use a raw query with entity framework: LINQ to Entities does not recognize the method ‘System.Linq.IQueryable…method, and this method cannot be translated into a store expression I was using FromQuery, and while I’m not too sure what was causing the issue, switching to…
-
Web API 2 – ExceptionMessage=No MediaTypeFormatter is available to read an object of type ‘HttpPostedFileBase’ from content with media type ‘multipart/form-data’.
Hi everyone, I ran into the following error while trying to get image uploads working with Web API 2: ExceptionMessage=No MediaTypeFormatter is available to read an object of type ‘HttpPostedFileBase’ from content with media type ‘multipart/form-data’. I had been trying to copy the following from an mvc controller in another project: public IHttpActionResult Upload(HttpPostedFileBase file,…
-
DbSet does not contain a definition for ‘FromSQL’ and no extension method ‘FromSql’ accepting an argument of type ‘DbSet’ could be found.
Hi everyone, I ran into the following error while attempting to use a custom query with EntityFramework: DbSet does not contain a definition for ‘FromSQL’ and no extension method ‘FromSql’ accepting an argument of type ‘DbSet’ could be found. This one’s pretty straight forward: // Install the following package via nuget Install-package Microsoft.EntityFrameworkCore.Relational //Add the…
-
Include UserId in Login Response (Token) – Web API 2
Hi everyone, A quick post on how to include the user’s id in your login response when using Web API 2. The default response to the /Token request is as follows: { “access_token”: “xxxxxxxxxxxxx_xxxx”, “token_type”: “bearer”, “expires_in”: 1209599, “userName”: “test@test.com”, “.issued”: “Mon, 23 Apr 2018 06:08:03 GMT”, “.expires”: “Mon, 07 May 2018 06:08:03 GMT” }…
-
Unsupported_Grant_Type – MVC Web Api (error)
Hi everyone, I ran into the following error while attempting to authenticate using .NET Web Api: POST http://localhost:63720/Token HTTP/1.1 Host: localhost:63720 Content-Type: application/json Content-Length: 0 HTTP/1.1 400 Bad Request Content-Type: application/json;charset=UTF-8 Date: Mon, 16 Apr 2018 14:18:06 GMT Content-Length: 34 {“error”:”unsupported_grant_type”} This one was pretty straight forward. Ensure that have the correct content-type: Content-Type: application/x-www-form-urlencoded…
-
Exited with code 9009 – Visual Studio Build
Hey everyone, I ran into the following error today while attempting to build a solution: combiner exited with code 9009 It apparently means that a file couldn’t be found. The solution was to simply restart visual studio. I’d been manually adding them to the directory and this is apparently a common cause. See the following…
-
Unable to Access RDS Database from Elastic Beanstalk Application
Hey everyone, I ran into a bit of an issue today where I was unable to access my RDS SQL Express instance from my .NET Elastic Beanstalk instance. I was receiving the following error: The server was not found or was not accessible. The solution turned out to be fairly simply thanks to this StackOverflow…