Questions tagged [asp.net-core-1.1]
Use this tag for questions specifically related to ASP.NET Core 1.1, in addition to using the 'ASP.NET Core' tag.
asp.net-core-1.1
298
questions
91
votes
11
answers
144k
views
How do I get current user in .NET Core Web API (from JWT Token)
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....
71
votes
6
answers
100k
views
connection string for sqlserver in Docker container
I'm using Visual Studio 2017 for mac with dotnet Core and EF Core. After setting up the mssql image in Docker container , I was trying to add the connection string but throwing connection error. I ...
58
votes
17
answers
144k
views
Error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
I'm trying to upgrade the following template project to ASP.NET Core 1.1:
https://github.com/wilanbigay/aspnet-core-aurelia-typescript-starter
After running dotnet migrate the project.json file has ...
54
votes
4
answers
124k
views
Entity Framework Core Using multiple DbContexts
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 ...
43
votes
4
answers
28k
views
ASP.NET Core 1.1 compiling with C# dynamic Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
I'm using Visual Studio 2017 RC and started a new ASP.NET Core project targeting the full .NET Framework.
This line of code will not compile.
dynamic handler = _container.GetService(handlerType);
...
31
votes
2
answers
15k
views
How to mock IOptionsSnapshot instance for testing
I have class AbClass that get with asp.net core built-in DI instance of IOptionsSnapshot<AbOptions> (dynamic configuration).
now I want to test this class.
I'm trying to instantiate AbClass ...
23
votes
2
answers
12k
views
.net core add Web Reference
I have two Web Project.
First of them is created about 2-3 weeks ago.
Second of them is created today.
I want to add Web Reference to the second web project.
First old Project Solution View
Second ...
19
votes
11
answers
17k
views
ASP.NET Core Scaffolding does not work in VS 2017
I have a beginner ASP.NET Core project in Visual Studio 2017, and I am at the scaffolding step of the HelloWorld. The Scaffolding does not work, I tested on a first computer, then at a second one...
...
19
votes
3
answers
36k
views
Environment variables configuration in .NET Core
I'm using the .NET Core 1.1 in my API and am struggling with a problem:
I need to have two levels of configurations: appsettings.json and environment variables.
I want to use the DI for my ...
17
votes
4
answers
29k
views
Specify a format for "asp-for" HTML Tag (ASP.NET Core)
In an ASP.NET Core project I have to display a (readonly) date in a specific format (say "dd/mm/yyyy HH:MM")
<div class="form-group">
<label asp-for="Date" class="col-md-2 control-label"&...
15
votes
6
answers
67k
views
'IServiceCollection' does not contain a definition for 'AddSession' [duplicate]
I am getting an error while adding 'AddSession' in ASP.Net Core 1.1 using VS2017.
'IServiceCollection' does not contain a definition for 'AddSession'
and no extension method 'AddSession' accepting a ...
15
votes
3
answers
24k
views
How to change VS 2017 RC .csproj project's target framework (from core to classic)?
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 ...
15
votes
3
answers
7k
views
Asp.Net core (Full .Net framework) vs Asp.Net core (.Net Core) Performance
I find that one of the key benefit of Asp.Net core is multi fold performance improvement (requests per second) compared to traditional Asp.Net. I find many bench mark sites talks about Asp.Net core ...
14
votes
4
answers
27k
views
How to POST via a link in ASP.NET Core
I try to POST to the SetLanguage action via a link, but not sure how to finalize the following code:
<form id="selectLanguage" asp-controller="Home" asp-action="SetLanguage" asp-route-returnUrl="@...
13
votes
3
answers
41k
views
Bad Request - Invalid Hostname when accessing localhost Web API or Web App from across LAN
I have an ASP .Net Core 1.1 Web API and Web App running on my localhost from Visual Studio 2017 on Windows 10.
When I run the projects, the API runs on http://localhost:50082/api/ and the web app on ...
12
votes
3
answers
8k
views
Custom Configuration Binder for Property
I'm using Configuration Binding in an ASP.NET Core 1.1 solution. Basically, I have some simple code for the binding in my ConfigureServices Startup section that looks like this:
services.AddSingleton(...
11
votes
2
answers
3k
views
Start a task with clean AsyncLocal state
In ASP.NET Core, I am using IHttpContextAccessor to access the current HttpContext. HttpContextAccessor uses AsyncLocal<T>.
In one situation, I am trying to start a Task from within a request, ...
11
votes
2
answers
494
views
Crazy Deep Path Length in .Net Core 1.1
Has anyone seen a problem in .NET Core 1.1 where beneath the netcoreapp1.1\publish folder they end up with a bin folder that seems to loop on itself and eventually causes a path too long message to ...
10
votes
3
answers
6k
views
View Component as a Tag Helper does not get Invoked
Invoking a View Component as a Tag Helper was introduced in ASP.NET Core 1.1. (See “Invoking a view component as a Tag Helper”). But the following only returns the Test for VC part of the view. It ...
9
votes
2
answers
2k
views
Override default indexes in AspNetCore.Identity tables
I'm developing a multi-tenant application in ASP.NET Core 2.1. I'm utilizing AspNetCore.Identity.EntityFrameworkCore framework for user management. I want to add a unique index combining ...
9
votes
5
answers
9k
views
Add Angular 4 to an ASP.NETCore Project
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 (...
8
votes
4
answers
16k
views
ASP.NET Core publish error: An error occurred while starting the application
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?
8
votes
2
answers
11k
views
String Route Constraint
I have an ASP .Net Core 1.1 MVC Web API. How can I have a string route constraint in a controller action?
I have the following two actions:
/ GET: api/Users/5
[HttpGet("{id:int}")]
[Authorize]
...
8
votes
2
answers
8k
views
asp.net core on linux with nginx routing doesn't work
I've created an ASP.NET Core MVC application and deployed it into Linux server. When I go to sitename.com browser shows up the Home/Index page without any problem.
But when I try to go sitename.com/...
8
votes
1
answer
9k
views
ASP.NET Core Identity impersonate specific user
Let's say I have the following roles:
Admin
User
I want Admin role to impersonate specific user account with User role, but without knowing that specific user account's password.
Admin should be ...
8
votes
1
answer
16k
views
Converting code from RestSharp to HttpClient
Could someone please help me convert this ASP .Net Core example (to be used in my Web Api to consume a management API from Auth0) which uses RestSharp into one using HttpClient?
var client = new ...
8
votes
1
answer
8k
views
View sql queries generated by EF Core
Is there anyway to see what SQL query EF Core is generating? (ASP .Net Core 1.1)
7
votes
1
answer
6k
views
Downloading byte[] of generated pdf using nodeservices in Asp.net Core 1.1
I'm trying to download a nodeServices generated pdf file that is in the form of byte array. here is my original code:
[HttpGet]
[Route("[action]/{appId}")]
public async Task<IActionResult> Pdf(...
7
votes
1
answer
17k
views
How to revoke JWT Bearer Token in .net core API
I have implemented JWT Bearer token base authentication and authorization. I am using the below code for destroying the JWT token or logout the current user but it's not working.
//var claim = ...
7
votes
3
answers
6k
views
The "CheckFileSystemCaseSensitive" task failed unexpectedly, Could not load file or assembly 'System.IO.FileSystem
To my Visual Studio 2017, ASP.NET Core, MVC web project I just added the Microsoft.TypeScript.MSBuild NuGet package v2.3.1, and simultaneously updated my ASP.NET Core assemblies from 1.0.* to 1.1.1. ...
7
votes
1
answer
2k
views
Override Existing Data Annotation Attribute in asp.net core 1.1
I am trying to override the RequiredAttribute in .net core and does not seem to work on asp.net core 1.1
Here is the test code
public class CustomRequiredAttribute : RequiredAttribute
{
public ...
7
votes
2
answers
2k
views
Convert MailMessage to MemoryStream in .net core
I am using the .Net Core 1.2 with Amazon SES(SimpleEmail) to send the Emails(Raw Emails).
Below is the working code version we have used in .net framework 4.5:
public MemoryStream ...
7
votes
0
answers
1k
views
How to ignore key unprotect errors
My application often fails with failed to unprotect session cookie (I am using two applications with different assembly versions).
Error unprotecting the session cookie. The key {hex_key} was not ...
6
votes
4
answers
22k
views
Accessing httpcontext in class library with ASP.NET Core 1.1 (MVC)
I am working on migrating my ASP.NET 4.6 framework code over to .NET Core. I'm only in the learning phase at this point. I'm new to MVC as I've always used WebForms, but I want to move away from ...
6
votes
2
answers
17k
views
How to obtain the ASP.NET Core application name?
I would like do display in the footer of an ASP.NET Core 1.1
© 2017 MyApplication
<p>© 2017 @(ApplicationName)</p>
How do I get the application name?
I found an ...
6
votes
1
answer
2k
views
using DependencyInjection in the Configure Method
In an ASP.NET CORE web application, I have a MyRepository class and an Interface IMyRepository that manages the access to the repository (database).
Each time a user connects to the application(on ...
6
votes
2
answers
3k
views
Recommended identity / user for Kestrel + .NET Core (Windows)
When using Kestrel with IIS you define an Application Pool and identity (user). The default identity is "ApplicationPoolIdentity" but can be one of the following or a custom user:
When the ...
6
votes
1
answer
5k
views
Managed Debugging Assistant 'FatalExecutionEngineError' 0xc0000005
Managed Debugging Assistant 'FatalExecutionEngineError' : 'The runtime
has encountered a fatal error. The address of the error was at
0x641ad419, on thread 0x5d0c. The error code is 0xc0000005. This ...
6
votes
0
answers
814
views
Unit test using HtmlHelper in ASP.NET Core
Although there are tag helpers now, you still need HtmlHelper from time to time, e.g., inside your tag helpers. I'm trying to write tests for one of my tag helpers which calls into HtmlHelper.
In ASP....
6
votes
2
answers
2k
views
Glimpse diagnostics platform which is full compatible to ASP.NET Core
I used Glimpse on the old ASP.NET MVC5 stack and liked it very much cause it gives a pretty and detailed representation of nearly all important data for debugging purpose. Sadly, its not compatible ...
5
votes
4
answers
17k
views
Could not load assembly Microsoft.EntityFrameworkCore.Design when running Add-Migration
I have created a Class Library project with the following .csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
...
5
votes
2
answers
17k
views
Why isn't FromQuery working in my ASP.Net Core 1.1 controller action
I am working on an ASP.Net Core 1.1 web API. I have a ServiceTypeCode controller as shown below;
[Produces("application/json")]
[Route("api/[controller]")]
public class ServiceTypeCodeController : ...
5
votes
3
answers
3k
views
XUnit Tests no longer discovered in .Net Core 1.1
I have just upgraded my Project to .Net Core 1.1 and all my tests are not discovered now. It was working fine when it was in the old version (.Net Core 1.0)
The following is the message in VS 2015 ...
5
votes
2
answers
960
views
Error after updating .net Core 1.0 to 1.1
I created new asp.net core web api project and updated to 1.1. I am getting following errors:
The project has not been restored or restore failed - run dotnet restore WebApplication1 C:\Program ...
5
votes
3
answers
2k
views
InvalidOperationException rendering ViewComponent in Strongly-Typed View
Recently updated dotnet core 1.0.1 to 1.1 and ViewComponent in MVC starts failing with the below exception:
InvalidOperationException: One or more errors occurred. (The model item passed into the ...
5
votes
1
answer
11k
views
How implement a timer with .NETCoreApp1.1
Before ASP.NET Core, I used to implement timers like that :
public class Class1
{
Timer tm = null;
public Class1()
{
this.tm.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
...
5
votes
0
answers
4k
views
call is ambiguous between the following methods System.Linq.Enumerable.ToList()
My asp.net solution has a class library that targets framework net 4.62. I'm getting an error when I call .ToList().
The call is ambiguous between the following methods or properties: System.Linq....
5
votes
1
answer
2k
views
Bearer error = Invalid_token 401 Unauthorized
var identity = new GenericIdentity(user.Username, "Token");
var claims = new List<Claim>();
claims.AddRange(identity.Claims);
foreach (RoleType r in ...
4
votes
2
answers
10k
views
The Language does not change in the ASP.NET Core Web application
I follow the Globalization and localization and Building simple multilingual ASP.NET Core website tutorials to add a language switch for my application.
So, I created a partial view
@using Microsoft....
4
votes
2
answers
8k
views
How to read configuration (appsettings) values inside attribute in .NET Core?
I have a .NET Core 1.1 Application with a custom attribute set on an action in the HomeController. Given the fact that I need a value from configuration file (appsettings.json) inside the attribute ...