Questions tagged [asp.net-core-middleware]

13331 questions
0

votes
0

answer
19

Views

How to connect on Angular web app with .Net Core Rest Api?

I'm trying to request my .Net Core REST Api, in an Angular web application. I've read something about enabling the CORS, so i did this: REST - Startup.cs public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get...
Salomé
0

votes
0

answer
14

Views

JWT Authentication .NET Core 2.2 doesn't update HttpContext

I've searched through some similar questions, but none helped me. I have the following situation: Basic JWT authentication in .NET Core 2.2, Startup.cs has its settings as: Startup.cs public void ConfigureServices(IServiceCollection services) { ... var signingConfigurations = new SigningConfiguratio...
Diego Penha
1

votes
0

answer
13

Views

How to unit test Tag Helper using IHtmlGenerator

I have created some Tag Helpers in AspNetCore that take IHtmlGenerator generator as the constructor. I want to create unit tests for these but I don't know what to pass in to the constructors. I see that the implementation is getting DefaultHtmlGenerator in the constructor but that, in turn, also...
heath
0

votes
0

answer
13

Views

Query values in IEnumerable<Claims> for access token

I am trying to query the value of app id within IEnumerable. By using Linq, I am not able to use select or where statement as x => x.appid is not present. Here's the code: var tokenS = jwtHandler.ReadToken(token) as JwtSecurityToken; var appId = tokenS.Claims.Where(x => x.key == 'appid').ToString()...
WW pana
0

votes
0

answer
10

Views

How can I get independent JSON reference resolution between requests in ASP.NET Core?

I am attempting to add a custom IReferenceResolver implementation to an ASP.NET Core 2.2 MVC API application to reduce data in a JSON payload. However the reference resolutions are being shared between different requests. It appears that a single instance of the ReferenceResolver is shared between r...
Simon Campbell
0

votes
0

answer
38

Views

SustainSys.Saml2 on ASP.NET Core 2 - GetExternalLoginInfoAsync() returns null

I'm integrating SustainSys.Saml2, with Gluu server as my IdP. I'm using the scaffolded Identity pages out of the box. When I run in localhost, and I view the console log everything seems to work with the SAML communication, and I even see a couple lines that read: Sustainsys.Saml2.AspNetCore2.Saml2H...
David
0

votes
0

answer
2

Views

How to use default output formatter when controller action results in BadRequest

I have a custom output formatter for producing csv output when accept header comes as text/csv. By default json format is used in cases no specific accept header is used as this is default dotnet core behavior. The problem is when the action produces a BadRequest result. The custom output formatter...
neo
0

votes
0

answer
11

Views

could not post to asp.net core web api using windows authentication

The api is AspNetCore WebApi with default configuration for Windows authentication and CORS enabled. The client is Angular with GET and POST methods. The GET call is successful: this.http.get('https://localhost:44358/api/values', {withCredentials:true}) .subscribe(a=> { console.log(a); this.list=a;...
beewest
0

votes
0

answer
8

Views

IdentityServer4 with AspNetIdentity - How to manage users

I have integrated AspNetIdentity into IdentityServer4 for user management. Previously I was using Auth0 and I had an admin page in my web application to change user claims which in turn called the management API for Auth0 to change user claim values. With IdentityServer4, as I integrated Identity fo...
Help123
0

votes
1

answer
5

Views

MVC controller with 2 parameters for filtering

Here is my controller. When 'mens' is passed into the URL(http://localhost:62498/Apparel/Mens), it renders the viewModel with mens apparel. There are many items on the page, which I would like to filter. My question is, how can I add another query string into the URL to filter which specific items I...
twofer
2

votes
0

answer
15

Views

How to Authorize Swagger to use MS Graph API

We are building a Web API wrapper for MS Graph API. I want to use Swagger to test my APIs. But I can't get the configuration right. I keep getting Bad Request and no other clue. I can't install Fiddler or other tools on this corporate laptop to help me investigate. Here is the Error And here is the...
jokab
0

votes
0

answer
6

Views

Api from Asp core controller not receive all the value that FormData.append(key,value) appended

I want to upload files(image, setup file) and some other text string together. This is my ajax code: function uploadFiles(inputId) { var input = document.getElementById(inputId); var files = input.files; formData = new FormData(); for (var i = 0; i !== files.length; i++) { var temp1 = files[i]; } fo...
Trí Chồn
1

votes
0

answer
32

Views

What are .NET Core patterns for using middleware objects in downstream projects?

Imagine the following project structure for a .NET Core Web project. Widget.UI project (MVC) calls Widget.Business calls Widget.Services calls Widget.Repository project. Let's say Widget.Services project wants to implement Distributed caching with Memcached. Is the pattern to add Memcached to midd...
AngryHacker
2

votes
3

answer
138

Views

Making Asp.Net core route first and then making to React route next

I am new to react but not to asp.net core application development. I am trying to create a react application with asp.net core + react template in visual studio. I am trying to do a Asp.Net MVC route first to call controller action which has [Authorize] attribute to make sure user is authenticated....
Kurkula
5

votes
0

answer
46

Views

Create, Update, Delete a $ref with ODate

After reading several tutorial I have a good idea how to implement a Rest API with OData. I can create, update and delete an entity and I can link existing entities to a collection of an entity. But what if my entity just contains another entity. Example, let's say I have a Course public class Cours...
Bastien Vandamme
1

votes
2

answer
909

Views

ASP.NET Core - Razor not checking for view embeded in assembly

I am trying to set up a pair of .NET Core project where one is a class library including a ViewComponent and the other is an ASP.NET Core MVC application which makes use of that component. I followed the guide here: http://www.strathweb.com/2016/01/re-using-external-view-components-in-asp-net-5-asp-...
Steve
1

votes
1

answer
1.7k

Views

C# how to add Await to this function - SendEmailAsync - MailKit in Dot Net Core

I have code based on MailKit. Where do I add the await keyword? public async Task SendEmailAsync(string email, string subject, string mess) { var message = new MimeMessage(); message.From.Add(new MailboxAddress('Joey Tribbiani', '[email protected]')); message.To.Add(new MailboxAddress('Mrs. Chanandle...
Arun Prasad E S
1

votes
4

answer
2.6k

Views

HttpContext.Current.Features.Get<IRequestCultureFeature>() is null in asp.net Core

I am trying to get the current culture from a user class in ASP.NET Core 1.1. I have the following under ConfigureServices in Startup.cs: services.AddSingleton(); services.Configure(options => { var supportedCultures = new List { new CultureInfo('en-US'), new CultureInfo('fil-PH') }; options.Default...
eat-sleep-code
1

votes
1

answer
265

Views

.net core Input tag helper does not appear to be rendering correctly

I have an issue where a .net core input tag helper does not appear to be rendering correctly. This is being rendered as: You will note the asp-for helper is not being re-rendered as a 'name' attribute. On another site, which uses essentially the same form, the input field is rendered correctly with...
eat-sleep-code
1

votes
2

answer
1.4k

Views

Lazy Loading not working in EntityFramework Core

Below are two classes that control database tables using Code First Entity Framework (DbContext). public class Employee { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string EmployeeName { get; set; } public int DepartmentId { get; set; } public Dep...
Sparked
1

votes
2

answer
905

Views

Docker Compose Nested Environment Variable

I have an existing app that uses a app config file that looks like: 'ConnectionInfo': { 'ServerName': 'The Server URL', 'DatabaseName': 'The DatabaseName', 'UserName': 'The User Name', 'Password': 'The Password'} Now, when I have a simple setting, say 'ConnectionString':'My Connection String' I unde...
Charles Gallo
1

votes
1

answer
463

Views

Automatic NugetPackage upload to Nuget feed

Is it possible to automatically upload a Nuget package to a feed when building a project using Visual Studio 2017 and .net core? I can check the option to automatically generate the package, but I don't know how to automate the publish process. Thanks!
user1275011
1

votes
1

answer
2.7k

Views

MVC Core adding Drop Down List to view

I'm trying to populate a drop down list in a view. I'm having problems with the razor syntax (I believe--only a couple days into this framework). I have seen multiple ways to do this; however, I'm interested in getting this to work so I can learn from it...:). Here's what I've got: My DataAccess...
Chris
1

votes
1

answer
100

Views

Dependency Injection DotNetCore Lifetime in the real world

Register in startup as Singleton, Scoped or Transient, Singleton means only a single instance will be created ever. Say we have a UserInfo services.AddSingleton(); and this UserInfo is populated somewhere else, might be middleware, or a service like factory with phoneNumber. email so on... If we us...
saj
1

votes
1

answer
14

Views

EF.Functions.Contains including multiple keywords

I need to search on multiple columns (LearningModuleDesc and LearningModuleContent which works using the || statements below) but I also need to search on multiple keywords. .Net Core 2.2 and EF Core does not support the string array with Contains (like the example below) but some guidance of how I...
W Morris
8

votes
1

answer
302

Views

How to catch ASP.NET Core 2 SignalR exceptions on server-side and handle them on client side with JavaScript?

Context: There are differences between ASP.NET SignalR and ASP.NET Core SignalR you can read here. As described in this stackoverflow post in ASP.NET SignalR you can catch unhandled exceptions on server side via the HubPipelineModule which not exists in ASP.NET Core SignalR. How can we catch unhand...
Simon
0

votes
0

answer
3

Views

Asp.net Boilerplate - There is no argument given that corresponds to the required formal parameter

Used ASP.NET boilerplate to create Multi Page Web Application (includes login, register, user, role and tenant management pages https://aspnetboilerplate.com/Templates) Getting below mention error while building the project. Kindly point me a direction to sort the mention issue. Thank-you. Error -...
coddey
1

votes
2

answer
964

Views

Access SignalR Hub without Constructor Injection

With AspNetCore.SignalR (1.0.0 preview1-final) and AspNetCore.All (2.0.6), how can I invoke a method on a hub in server code that is not directly in a Controller and is in a class that cannot be made via Dependency Injection? Most examples assume the server code is in a Controller and should 'ask' f...
Glen Little
1

votes
1

answer
467

Views

.NET Core ASP.NET Controller with Session and tests

I have my web project in .NET Core 2.x. In the Login Controller, after the login, I save a token in the Session to have this token across pages. My problem started when I wanted to test all controllers. If I call a controller from a test, HttpContext.Session is null. Then I found this Mock for Sessi...
Enrico
1

votes
2

answer
834

Views

Using ADO.NET for a Data Access Layer in ASP.NET Core

I'm trying to roll a high performance DAL for my ASP.NET Core API. I want to use ADO.NET and I am having difficulty designing the software architecture. I'm looking for help discussing a good approach. What I Have My codebase will consist of three projects MyApp.API MyApp.Repositories (data access l...
clenard
1

votes
3

answer
885

Views

.Net Core 2.1 - Read appsettings.json in javascript file

I have a Web application in .net Core 2.1 using signalR. I need to pass HubUrl into custom javascript file. Is that possible in .net Core? Sample of js code: const connection = new signalR.HubConnectionBuilder() .withUrl('http://localhost:5000/hub') //Here I need to read appSettings.json to get val...
k1dl3r
5

votes
0

answer
36

Views

Trying to add clients in a group inside SignalR but not working

When I try to work with groups in SignalR, I have something strange. I did a class for my hub where there's Task which works when I ping all clients. I have done Two methods wich one is to add and the second to remove clients from a group. But when I try to had a client inside a group, there's nothi...
thelittlewozniak
1

votes
1

answer
39

Views

AWS .NET SDK, AliasTarget record set issues

EDIT Solved, the solution is in the comments. I'm trying to create a record set in AWS Route53 that targets an alias CloudFront distribution. At the moment, I'm creating a new hosted zone with the desired domain (works fine). Afterward, I'm taking the HostedZoneId from the response and trying to cre...
Ben
1

votes
1

answer
77

Views

.net core create on memory zipfile

I am working on an MVC project where I create dynamically pdf files(wkhtmltopdf) which I want to return in a zip file. The pdf files are generated on fly - I don't need to store them, so my code to return a single file is: File(pdfBytes, 'application/pdf', 'file_name') Taking a look on Microsoft doc...
George George
1

votes
1

answer
44

Views

asp.core page razor enum dropdownlist

I use Asp.Core 2.1 with 'Page Razor Crud' and I want into my page show a dropdownlist. Here's my model: public enum EnumStatus { Waiting, [Display(Name = 'Development progress')] Progress, Canceled, Refused, Deployed, } public class Improvement { [Key] public int ID { get; set; } public string Titl...
Yann Btd
1

votes
2

answer
96

Views

ASP.NET Core 3.0 not showing on Visual Studio 2019 RC

I want to test the new Razor Components framework. I installed Visual Studio 2019 RC, and then the .Net Core 3.0 preview 2, following this official tutorial. After the install, I only see the ASP.NET Core 2.0 and the 2.1 on the 'Create a new ASP.NET Core Web Application' page. The 3.0 is not showing...
Guilherme
1

votes
2

answer
40

Views

Increase timeout in Angular 2+ and ASP.NET Core WebAPI application

In my Angular 2+ / ASP.NET Core MVC WebAPI application I have a long running API-call from the client UI to the server. The request times out after 30 seconds. I would like to define the timeout for this specific API call either client- or server-side. I have only found ways to configure the server...
Marc
1

votes
2

answer
28

Views

Where to put web scrape logic in MVC

I'm building a .NET Core MVC application. It has a single endpoint that retrieves an imdb id of a movie by scraping the imdb site. So my question is, where do I put the logic to get the id? My original project structure is shown below. +--Controller +--Entry point api call +--Logic +--Class that re...
user3736114
1

votes
2

answer
67

Views

ObjectDisposedException thrown when trying to save files to a DbContext

I am uploading a text file and writing each split line to a database. The file has over a million lines. The upload and saving to the database works but breaks after the save on the await _context.SaveChangesAsync(); line with the following error System.ObjectDisposedException HResult=0x80131622 Mes...
Narian Naidoo
0

votes
0

answer
4

Views

Logo not showing in navbar in ASP.net _layout.cshtml

I am a newbie in asp.net. I m trying to add a logo in my _layout.cshtml file but it's not getting into view. It's showing a broken image. The image is in Assets folder. Don't know what I am doing wrong. Any help would be appreciated. Here's the screenshot of my code and structure.
Mohammad Quanit

View additional questions