asp.net-core-1.1

How do I get current user in .NET Core Web API (from JWT Token)

試著忘記壹切 提交于 2019-12-02 20:16:51
After a lot of struggling (and a lot of tuturials, guides, etc) I managed to setup a small .NET Core REST Web API with an Auth Controller issuing JWT tokens when stored username and password are valid. The token stores the user id as sub claim. I also managed to setup the Web API to validate those tokens when a method uses the Authorize annotation. app.UseJwtBearerAuthentication(...) Now my question: How do I read the user id (stored in the subject claim) in my controllers (in a Web API)? It is basically this question ( How do I get current user in ASP .NET Core ) but I need an answer for a

How to Response.Cookies.Append() in ASP.Net Core 1.1?

北城以北 提交于 2019-12-02 06:20:38
问题 I am trying to add Globalization to an Intranet application, using a cookie to allow users a culture preference. The middleware is set up and running but I have run into an issue with appending to the cookie based on the UI selection. The method is straight from the Asp.Net Core documentation as below: public void ConfigureServices(IServiceCollection services) { services.Configure<RequestLocalizationOptions>( options => { var supportedCultures = new List<CultureInfo> { new CultureInfo("en-US"

How to Response.Cookies.Append() in ASP.Net Core 1.1?

烂漫一生 提交于 2019-12-02 00:52:05
I am trying to add Globalization to an Intranet application, using a cookie to allow users a culture preference. The middleware is set up and running but I have run into an issue with appending to the cookie based on the UI selection. The method is straight from the Asp.Net Core documentation as below: public void ConfigureServices(IServiceCollection services) { services.Configure<RequestLocalizationOptions>( options => { var supportedCultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("en-GB"), new CultureInfo("fr-FR"), new CultureInfo("es-ES") }; options

How to change VS 2017 RC .csproj project's target framework (from core to classic)?

好久不见. 提交于 2019-11-30 05:16:43
How to change target framework with VS 2017 RC in new core asp "csproj" projects? I mean to change after project was created. There are no project.json file which was used for that in VS 2015. In project properties in targets "pull down" there are no other options then ".NETCoreApp 1.1" and ".NETCoreApp 1.0". Details: I have used yoman to generate SPA project: http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/ so I was unable to select .NET Framework during the csproj creation. What to do now? Edit csproj file this way: <TargetFramework>netcoreapp1.1<

Add Angular 4 to an ASP.NETCore Project

隐身守侯 提交于 2019-11-29 07:06:32
I want to utilize Angular 4 in my ASP.NetCore 1.1 project, within Visual Studio 2017 (read as: *.csproj file) Previously with ASP.NET Core 1.0 and Visual Studio 2015, you could simply add AngularJS (1.x.x) into the project.json as a dependency and it would wire itself in. Now, with ASP.NetCore and VS2017, the project.json file has gone away, and the only documentation I can find refers to STARTING an Angular 4 project by using the CLI and using the CLI to generate a NEW angular app. I don't really want a new project or have to refactor everything I have created to provide a service to a

How to change VS 2017 RC .csproj project's target framework (from core to classic)?

人盡茶涼 提交于 2019-11-29 02:49:06
问题 How to change target framework with VS 2017 RC in new core asp "csproj" projects? I mean to change after project was created. There are no project.json file which was used for that in VS 2015. In project properties in targets "pull down" there are no other options then ".NETCoreApp 1.1" and ".NETCoreApp 1.0". Details: I have used yoman to generate SPA project: http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/ so I was unable to select .NET Framework

ASP.NET Core publish error: An error occurred while starting the application

一世执手 提交于 2019-11-28 14:03:32
I tried to publish my ASP.NET Core application on Windows Server 2008 R2 but I get this error: "An error occurred while starting the application." Without any more description! What can I do? Please take a look at this post: https://scottsauber.com/2017/04/10/how-to-troubleshoot-an-error-occurred-while-starting-the-application-in-asp-net-core-on-iis which will give you a good starter kit to get basic log informations when this kind of error appear. It may be a bad startup configuration or related to the .NET Core runtime installed but very difficult to say without more technical information.

Add Angular 4 to an ASP.NETCore Project

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 00:40:43
问题 I want to utilize Angular 4 in my ASP.NetCore 1.1 project, within Visual Studio 2017 (read as: *.csproj file) Previously with ASP.NET Core 1.0 and Visual Studio 2015, you could simply add AngularJS (1.x.x) into the project.json as a dependency and it would wire itself in. Now, with ASP.NetCore and VS2017, the project.json file has gone away, and the only documentation I can find refers to STARTING an Angular 4 project by using the CLI and using the CLI to generate a NEW angular app. I don't

ASP.NET Core publish error: An error occurred while starting the application

爷,独闯天下 提交于 2019-11-27 08:10:14
问题 I tried to publish my ASP.NET Core application on Windows Server 2008 R2 but I get this error: "An error occurred while starting the application." Without any more description! What can I do? 回答1: Please take a look at this post: https://scottsauber.com/2017/04/10/how-to-troubleshoot-an-error-occurred-while-starting-the-application-in-asp-net-core-on-iis which will give you a good starter kit to get basic log informations when this kind of error appear. It may be a bad startup configuration

Entity Framework Core Using multiple DbContexts

霸气de小男生 提交于 2019-11-27 00:14:36
问题 I'm having a problem that when I try to access a field in my PartsDbContext I get the following error: System.Data.SqlClient.SqlException: 'Invalid object name 'fieldName'' It seems that this is because I'm trying to make my PartsDbContext use the same database as my ApplicationDbContext which is used with Identity. I need to know how to setup a 2nd dbcontext to work with EF core that uses/creates a different database. I've tried creating a 2nd connection string but that gets me this error: