asp.net-core-1.0

Copying files on compile for Asp.net Core 1.0 project

╄→尐↘猪︶ㄣ 提交于 2019-12-07 07:11:35
问题 I'm creating a REST Api with Asp.Net Core 1.0 and I want to copy a file which is not in included in the project to the output path when the project is compiled. I can't figure out how to do it though. I have tried to use "buildOptions: copyToOutput" without any success. I can't really understand the project.json reference found here: https://docs.microsoft.com/en-us/dotnet/articles/core/tools/project-json Say that I want to copy the file ....\TestFolder\Test.config to the output folder of the

Scaffolding in .Net Core with Multiple Projects in Solution

痞子三分冷 提交于 2019-12-07 06:05:48
问题 I have created an .Net Core MVC6 application targeting net461. I have used a project structure I am very familiar with in which I place the data, model, and service classes in separate class library projects and the Web project references these. When I attempt to scaffold a controller I receive an error that multiple matching types exist for the model I am scaffolding. If I move all code to a single project, scaffolding is successful. If I move the context to Web project and leave the model

WebTelemetryInitializerBase in ASP.NET Core / MVC6

江枫思渺然 提交于 2019-12-07 05:09:26
问题 Is there an MVC6 compatible version of WebTelemetryInitializerBase that would work with ASP.NET Core (on the full .NET Framework)? See my question here where I asked how to get HttpContext in my temeletry initializers. Unfortunately I didn't specify that I was using MVC 6 and thus no System.Web.HttpContext . 回答1: Yes, there is a version of this for aspnetcore. Check out the Microsoft Application Insights for ASP.NET Core applications repo. There is an implementation of getting the WebUser

Route controller and action in middleware

孤者浪人 提交于 2019-12-07 04:15:41
问题 I am trying to retrieve the controller and action, I have tried to this point by using var routeData = context.GetRouteData(); inside the middleware's Invoke method, but it yields null every time. Is it possible at all to retrieve route data in middleware? What I am trying to achieve is to check whether the requested action has a [RequireToken] attribute, and if so, it will check the incoming headers for a specific token. 回答1: The action/controller context is very specific to the MVC portion

Accessing the IHostingEnvironment in static main of ASP.NET Core

◇◆丶佛笑我妖孽 提交于 2019-12-07 04:09:45
问题 I'm attempting to get configuration values in my static void main of my upgraded Asp.Net Core RC2 application. In the constructor for Startup, I can get IHostingEnvironment injected in, but can't do that in a static method. I'm following https://github.com/aspnet/KestrelHttpServer/blob/dev/samples/SampleApp/Startup.cs, but want to have my pfx password in appsettings (yes, it should be in user secrets and will get there eventually). public Startup(IHostingEnvironment env){} public static void

How do I debug an ASPNET Core MVC Application Deployed in Azure

[亡魂溺海] 提交于 2019-12-07 03:29:10
问题 I've created a simple ASPNET Core 1.0 MVC app, which I am trying to deploy to Azure using Visual Studio. I am able to run this app locally on my machine using IIS Express, and navigate to my default route and display the page. However, in Azure I always get a 500 error every time, and at this point I am at a loss for how to get additional information. I've enabled detailed request logging in my Azure app, but it doesn't really seem to tell me much. ModuleName="AspNetCoreModule", Notification=

Configure .NET Core to use x86 SDK

China☆狼群 提交于 2019-12-07 03:01:43
问题 I'm trying to change my .NET Core Web Application to use the x86 version of the .NET Core SDK. I installed the x86 version from here. I can see it in C:\Program Files (x86)\dotnet\sdk\1.0.0-preview2-003131 I updated my global.json to this: { "projects": [ "src" ], "sdk": { "version": "1.0.0-preview2-003131", "architecture": "x86" } } But I get the error: The project is configured to use .NET Core SDK version 1.0.0-preview2-003131 which is not installed or cannot be found under the path C:

Populating Dropdown in ASP.net Core

こ雲淡風輕ζ 提交于 2019-12-07 00:35:54
问题 Does anyone know how to deal with Dropdowns in Asp.net core. I think I made myself very complicated to understand the new Asp.net core concept. (I am new to Asp.net Core). I have models called Driver , Vehicle . Basically one can create bunch of vehicles in the master then attach it to the Driver. So that the driver will be associated with a vehicle. My problem is that I am also using viewmodel in some area to combine two different models.(understood little from default template) My problem

Read an excel file on asp.net core 1.0

ぐ巨炮叔叔 提交于 2019-12-06 18:18:18
问题 Hello I`m trying to upload and read an excel file on my asp.net project but all the documentation I find is for ASP MVC 5. My goal is to read the excel sheet and pass the values to an list of objects. This is my controller, it works for upload the file to my wwwroot/uploads public class HomeController : Controller { private IHostingEnvironment _environment; public HomeController(IHostingEnvironment environment) { _environment = environment; } public IActionResult index() { return View(); }

Library NuGet configuration is invalid

本秂侑毒 提交于 2019-12-06 17:02:27
问题 VS2015 Update 3. I created a plain .net core class library. Right-click on Project->References-> Manage Nuget packages throws the following error? What is missing? 回答1: Try the following: Restart VS and see if this fixes your problem If restarting didn't help, try to delete nuget.config, explained below. Previous solution from year 2012 (Obsolete?) : At the time I wrote this, the below approach worked for me: Just delete the nuget.config which resides here: %AppData%/Nuget/Nuget.config or the