Questions tagged [asp.net-core-1.0]

Use this tag for questions specifically related to ASP.NET Core 1.0, in addition to using the 'ASP.NET Core' tag. ASP.NET Core 1.0 was the first release of ASP.NET Core and was originally intended to be ASP.NET 5.

Originally planned to be ASP.NET 5, it was re-imagined as a fresh start during development and instead became a clean a clean break from the System.Web namespace that classic ASP.NET apps use. This is the first release of that work.

See the tag asp.net-core for more information or Microsoft Docs for even more details

880 questions
224
votes
18 answers

How to get the current logged in user ID in ASP.NET Core?

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.
MRainzo
  • 3,084
  • 2
  • 13
  • 24
143
votes
12 answers

How to read connection string in .NET Core?

I want to read just a connection string from a configuration file and for this add a file with the name "appsettings.json" to my project and add this content on it: { "ConnectionStrings": { "DefaultConnection":…
motevalizadeh
  • 4,259
  • 11
  • 49
  • 89
128
votes
11 answers

How to get current url in view in asp.net core 1.0

In previous versions of asp.net, we could use @Request.Url.AbsoluteUri But it seems it's changed. How can we do that in asp.net core 1.0?
oneNiceFriend
  • 6,061
  • 7
  • 27
  • 37
100
votes
8 answers

JSON properties now lower case on swap from ASP .Net Core 1.0.0-rc2-final to 1.0.0

I've just swapped our project from ASP .Net Core 1.0.0-rc2-final to 1.0.0. Our website and client have stopped working because of the capitalization of JSON properties. For example, this line of JavaScript now fails for (var i = 0; i <…
dumbledad
  • 12,928
  • 20
  • 97
  • 226
82
votes
13 answers

No executable found matching command "dotnet-ef"

I'm doing a project sample by using ASP.Net Core RC2 with Microsoft.EntityFramework.Core and SQLite. I've followed this tutorial: https://damienbod.com/2015/08/30/asp-net-5-with-sqlite-and-entity-framework-7/ But, when I run this command : dotnet…
Redplane
  • 2,621
  • 2
  • 25
  • 48
67
votes
12 answers

How to publish environment specific appsettings in .Net core app?

I have 3 environment specific appsettings files in my .Net core application in project.json I have setup publishOptions like this. ( based on suggestion here) "publishOptions": { "include": [ "wwwroot", …
LP13
  • 20,711
  • 38
  • 136
  • 286
65
votes
8 answers

.NET Core: Remove null fields from API JSON response

On a global level in .NET Core 1.0 (all API responses), how can I configure Startup.cs so that null fields are removed/ignored in JSON responses? Using Newtonsoft.Json, you can apply the following attribute to a property, but I'd like to avoid…
dotNetkow
  • 4,365
  • 4
  • 33
  • 48
63
votes
2 answers

How to save IFormFile to disk?

I'm trying to save a file on disk using this piece of code. IHostingEnvironment _hostingEnvironment; public ProfileController(IHostingEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; } [HttpPost] public async…
Richard77
  • 17,505
  • 36
  • 124
  • 222
57
votes
2 answers

Equivalent for .HasOptional in Entity Framework Core 1 (EF7)

Consider two classes. public class File { [Key] public string Id { get; set; } public string Message_Id { get; set; } internal Message Message { get; set; } } public class Message { [Key] public string Id { get; set; } …
56
votes
1 answer

Replacement of AssemblyBuilder.DefineDynamicAssembly in .NET Core

How do I port the following code to .NET Core? AppDomain.CurrentDomain.DefineDynamicAssembly( new AssemblyName( Guid.NewGuid().ToString()), AssemblyBuilderAccess.RunAndSave); Is it possible?
MaGu
  • 805
  • 2
  • 8
  • 12
54
votes
6 answers

Read appsettings.json in Main Program.cs

First of all my main purpose is to setup the IP and Port for my application dynamically. I'm using IConfiguration to inject a json config file, like some tutorial mentioned. However, I can't retrieve the configuration in Program.cs, because my…
Jacky
  • 2,348
  • 3
  • 20
  • 31
54
votes
5 answers

Basic Authentication in ASP.NET Core

Question How can I implement Basic Authentication with Custom Membership in an ASP.NET Core web application? Notes In MVC 5 I was using the instructions in this article which requires adding a module in the WebConfig. I am still deploying my new…
52
votes
10 answers

How to get "Manage User Secrets" in a .NET Core console-application?

When I create a new ASP .NET Core Web-Application, I can right-click the project in Visual Studio, and I see a context-menu entry called "Manage User Secrets". When I create a new .NET Core Console-Application, I don't see this context-menu entry.…
user6038265
49
votes
5 answers

How to set .NET Core in #if statement for compilation

I created a multi-targeted framework project. I use something like this: #if NET40 Console.WriteLine("Hello from .NET Core 4"); #endif But I can't find a wildcard for .NET Core. I tried: #if NETCOREAPP1.0 Console.WriteLine("Hello…
49
votes
3 answers

asp.net core 1.0 web api use camelcase

On RC2 the same code returns json format with camel case. After netcore 1.0 release i started new project and the same code is returning json in lowercase. Tried multiple solutions but none of them were…
Brivvirs
  • 2,369
  • 2
  • 15
  • 27
1
2 3
58 59