asp.net-core-1.1

'IServiceCollection' does not contain a definition for 'AddSession'

我与影子孤独终老i 提交于 2020-01-12 14:03:14
问题 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 first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?) .csproj <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <PropertyGroup> <PackageTargetFallback>$

Angular4.1 with .NET Core1.1 build fails in VSTS Hosted VS2017 agent

霸气de小男生 提交于 2020-01-07 03:48:45
问题 I have an Angular 4.1.1 app sitting on .NET Core 1.1 which I recently migrated from VS2015 w/update 3 to VS2017. My csproj builds and runs fine on my local machine but fails when setting up a build on VSTS via their hosted VS2017 agent. The failure occurs during the "Build" step and here is the portion of the log file indicating the reason: Installed: 2017-05-27T14:23:05.5884539Z 301 package(s) to d:\a\1\s\src\MyApp.Web\MyApp.Web.csproj 2017-05-27T14:23:05.6244543Z ##[section]Finishing:

How to clear cacheKey in separate instance of IMemoryCache

蹲街弑〆低调 提交于 2020-01-06 10:07:47
问题 I'm running on ASP.NET Core 1.1 where in my Startup.cs I configure Policies, as well as DistributedMemoryCache , like this: var roleRepo = new RoleRepo(Configuration, new MemoryCache(new MemoryCacheOptions())); services.Configure<AuthorizationOptions>(options => { options.AddPolicy("MyPolicy", policy => policy.Requirements.Add(new MyPolicyRoleRequirement(roleRepo))); }); services.AddDistributedMemoryCache(); //... services.AddTransient<IRoleRepo, RoleRepo>(); The problem I'm having is I'm

How to clear cacheKey in separate instance of IMemoryCache

ε祈祈猫儿з 提交于 2020-01-06 10:05:19
问题 I'm running on ASP.NET Core 1.1 where in my Startup.cs I configure Policies, as well as DistributedMemoryCache , like this: var roleRepo = new RoleRepo(Configuration, new MemoryCache(new MemoryCacheOptions())); services.Configure<AuthorizationOptions>(options => { options.AddPolicy("MyPolicy", policy => policy.Requirements.Add(new MyPolicyRoleRequirement(roleRepo))); }); services.AddDistributedMemoryCache(); //... services.AddTransient<IRoleRepo, RoleRepo>(); The problem I'm having is I'm

Bad Request - Invalid Hostname when accessing localhost Web API or Web App from across LAN

谁都会走 提交于 2020-01-02 03:28:27
问题 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 http://localhost:60856/ However, if others on the LAN try to access it (using my computer's IP address - http://192.168.1.101:60856/ they get a Bad Request - Invalid Hostname Error. In fact,. I get this error too of I use my IP address. I've tried about a dozen variations in my C:\Users\Documents

C# IFormFile as ZipFile

可紊 提交于 2019-12-24 18:31:13
问题 I have a REST API endpoint which receives zip file on .Net Core 1.1. I'm getting IFormFile from request like this var zipFile = HttpContext.Request.Form.Files.FirstOrDefault(); And then I need to pass it to service method from .Net Standard 1.5, where IFormFile is not supported. So the question is: how can I convert IFormFile to ZipFile or to some other type which is supported in Standard 1.5, or maybe there is some more proper way to operate with zip files? Thanks! 回答1: IFormFile is just a

How to Generate Custom Key Number Using C# in ASP.NET Core

≡放荡痞女 提交于 2019-12-23 16:45:57
问题 this my class, public class PatReg { [DatabaseGenerated(DatabaseGeneratedOption.Computed), ScaffoldColumn(false)] public Int64 RecId { get; set; } [Key,Display(Name = "File Id"), ScaffoldColumn(true), DatabaseGenerated(DatabaseGeneratedOption.None )] public Int64 FileId { get; set; } [Required, Display(Name = "First Name")] public string FName { get; set; } [Required, Display(Name = "Middle Name")] public string MName { get; set; } [Required, Display(Name = "Last Name")] public string LName {

The Language does not change in the ASP.NET Core Web application

一个人想着一个人 提交于 2019-12-23 03:40:28
问题 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.AspNetCore.Builder @using Microsoft.AspNetCore.Http.Features @using Microsoft.AspNetCore.Localization @using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.Extensions.Options @inject IViewLocalizer Localizer @inject IOptions<RequestLocalizationOptions> LocOptions @{ var requestCulture =

Glimpse diagnostics platform which is full compatible to ASP.NET Core

妖精的绣舞 提交于 2019-12-22 05:14:51
问题 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 with ASP.NET Core (yet). I tried to install the demo, which assurance to work with ASP.NET Core. But thats not entirely true cause it works on ASP.NET Core, but depends on the old 4.x framework. So it destroys the cross-platform compability, which is not suiteable for me. The app is designed to run

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

南笙酒味 提交于 2019-12-20 09:28:16
问题 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