asp.net-core-1.0

How to disable TypeScript compilation in .Net Core projects?

放肆的年华 提交于 2019-11-27 02:34:15
问题 I have a Visual Studio 2015 ASP.Net Core project that contains a folder of typescript files. My question is how can I prevent VS from trying to compile the TypeScript files? I don't want them compiled, either on save or build. I have tried added the project setting below, but it doesn't seem to have any impact. <PropertyGroup> <TypeScriptCompileOnSaveEnabled>False</TypeScriptCompileOnSaveEnabled> </PropertyGroup> Currently VS is throwing an error, tsc.exe exited with code 1 , but as stated, I

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

﹥>﹥吖頭↗ 提交于 2019-11-26 23:46:21
I've done this before with MVC5 using User.Identity.GetUserId() but that doesn't seem to work here. The User.Identity doesnt have the GetUserId() method I am using Microsoft.AspNet.Identity AdrienTorris Until ASP.NET Core 1.0 RC1 : It's User.GetUserId() from System.Security.Claims namespace. Since ASP.NET Core 1.0 RC2 : You now have to use UserManager . You can create a method to get the current user : private Task<ApplicationUser> GetCurrentUserAsync() => _userManager.GetUserAsync(HttpContext.User); And get user information with the object : var user = await GetCurrentUserAsync(); var userId

.NET Core and Angular 2 Work Flow

只谈情不闲聊 提交于 2019-11-26 21:56:23
问题 I am wondering what the correct filing structure is for setting up a .NET Core 1.0.0 MVC application with Angular 2. I have browsed various tutorials and lectures but they all seem to have different ways of implementing angular 2 into .NET. Also, what are the best practices for implementing angular 2 into a .NET MVC app (a.k.a. when should I use angular SPA practices vs. using POST/GET with .NET) and how should I correctly setup the work flow? Thank you. 回答1: I use asp.net in conjunction with

ASP.NET Core RC2 SignalR Hub Context outside request thread

时光总嘲笑我的痴心妄想 提交于 2019-11-26 18:12:28
问题 I am currently trying out the RC2 release of ASP.NET Core and I am running into an issue with SignalR . I need to be able to send messages to the client outside of the request thread. Now in the full .NET framework you can do this like: var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); context.Clients.<SendMessage>() But in ASP.NET Core there is no GlobalHost . I found a similar question: How to get SignalR Hub Context in a vNext Project? Where the second answer provides a

How to add IHttpContextAccessor in the Startup class in the DI in ASP.NET Core 1.0?

不问归期 提交于 2019-11-26 17:41:27
问题 In ASP.NET Core RC 1 I used the following code to retrieve the value of context (full address of the page). Then I recorded this value in the configuration. public class Startup { public IConfigurationRoot Configuration { get; set; } private IHostingEnvironment CurrentEnvironment { get; set; } private IHttpContextAccessor HttpContextAccessor { get; set; } public Startup(IHostingEnvironment env, IHttpContextAccessor httpContextAccessor) { var builder = new ConfigurationBuilder() .SetBasePath

No executable found matching command “dotnet-ef”

眉间皱痕 提交于 2019-11-26 17:34:31
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 ef migrations add FirstMigration I got this error : No executable found matching command "dotnet-ef" Here is my project.json configuration: { "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702", "type": "platform" }, "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",

Injection of IUrlHelper in ASP.NET Core

▼魔方 西西 提交于 2019-11-26 16:59:48
问题 In RC1 , IUrlHelper could be injected in services (with services.AddMvc() in startup class) This doesn't work anymore in RC2 . Does anybody know how to do it in RC2 as just newing up a UrlHelper requires an ActionContext object. Don't know how to get that outside a controller. 回答1: For ASP.NET Core RC2 there is an issue for this on the github repo. Instead of injecting the IUrlHelper , take an IUrlHelperFactory . It also sounds like you'd need the IActionContextAccessor injected as a

ASP.NET Core MVC controllers in separate assembly

穿精又带淫゛_ 提交于 2019-11-26 16:39:11
问题 I'm using ASP.NET MVC Core RC-2. I have a web project targeting the full .NET framework. I also have a separate class library in the solution, also targeting the full framework. In the class library, I have a controller, marked with a route attribute. I have referenced the class library from the web project. This assembly references the nuget package Microsoft.AspNetCore.Mvc v. 1.0.0-rc2-final . It was my understanding that this external controller would be discovered automatically, e.g. http

Override global authorize filter in ASP.NET Core 1.0 MVC

时光怂恿深爱的人放手 提交于 2019-11-26 16:01:55
问题 I am trying to set up authorization in ASP.NET Core 1.0 (MVC 6) web app. More restrictive approach - by default I want to restrict all controllers and action methods to users with Admin role. So, I am adding a global authorize attribute like: AuthorizationPolicy requireAdminRole = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .RequireRole("Admin") .Build(); services.AddMvc(options => { options.Filters.Add(new AuthorizeFilter(requireAdminRole));}); Then I want to allow users

AWS Elastic Beanstalk environment variables in ASP.NET Core 1.0

 ̄綄美尐妖づ 提交于 2019-11-26 15:46:03
问题 How do I get environment variables from elastic beanstalk into an asp.net core mvc application? I have added a .ebextensions folder with app.config file in it with the following: option_settings: - option_name: HelloWorld value: placeholder - option_name: ASPNETCORE_ENVIRONMENT value: placeholder The .ebextensions folder is included in the publish package. On deployment, both the variables are visible in the aws elasticbeanstalk console at Configuration > Software Configuration > Environment