Questions tagged [.net-core]

15039 questions
-1

votes
1

answer
23

Views

Asp.Net Core site doesn't have 4x framework available? [duplicate]

This question already has an answer here: ASP NET Core 2 with Full Framework 1 answer I'm just getting started using .Net Core and at work our servers only have 4.6.2 installed. We will not be able to install Core 2.2+ for at least another 6 months and maybe up to the beginning of next year. To sta...
Caverman
0

votes
1

answer
32

Views

Why is c# Parallel.ForEach not creating too many open connections in my c# app?

I had some problems in my code causing too many open connections which causes them to close and get no http response. I have since refactored into something that looks like this: List { var res = Client.GetAsync(batchItem.Item1).GetAwaiter().GetResult(); var responseBody = res.Content.ReadAsStringAs...
Craig
0

votes
0

answer
8

Views

Model invalid when adding in Post

I have a Razor Page which submits most of the required fields for MyUser, however, some I want created manually before adding to the database. public async Task OnPostAsync() { //Other MyUser attributes set using form MyUser.Date = DateTime.Now; MyUser.Name = User.Identity.Name; MyUser.Details = "S...
Hawke
1

votes
0

answer
19

Views

Create an EF Core DbContext at runtime based on request parameters

Background We are building a web application using ASP.Net Core and Entity Framework Core 2.2 We are connecting to legacy databases. The setup is that there are 16 databases, all with the exact same schema, holding different contextual data. We cannot change this. We have a requirement to connect to...
JTech
0

votes
0

answer
10

Views

How do I pass a Controller (controllername) as parameter to another method?

so I'm wondering if it's possible to send a Controller as a parameter to another method. What I'm trying to acomplish is to create a method that acts like a Filepath builder by taking two parameters (controllername and method name). I have a method in a Controller as shown below: public async Task...
K.Oleksiak
4

votes
1

answer
27

Views

How to work with ASP.Net Core Identity with Web API Core and Angular 6

Please do help me out for this. I am using technologies: Asp.Net core 2.1 Web API core 2.1, Entity Framework core 2.1 Angular 6. We wanted to integrate Asp.Net core identity for Authentication and Authorization, Please do help me out for this, Below is the structure of my project,
Sharad
1

votes
2

answer
798

Views

Razor white page when render server side commands(Asp.net 5)?

First of all sorry my bad english. When I try to view the url / for my HomeController and an Index action, all I get is a white page. I'm starting from the empty ASP.NET 5 Web Application template and then I'm adding Controllers\HomeController.cs. Next, I'm adding the Home folder under Views and fin...
Hasan Tuna Oruç
1

votes
1

answer
2.1k

Views

Cannot use table 'AspNetUsers' in schema '' for entity 'AspNetUsers' since it is being used for another entity

We are trying to add Identity 3 to our existing Customers app by extending AspNetUsers public class ApplicationUser : IdentityUser { public string BusinessName { get; set; } public string ContactName { get; set; } public string CountryCode { get; set; } public virtual Countries Country { get; set; }...
Vague
1

votes
3

answer
2k

Views

Running .net core application on a chromebook

I have developed a asp.net 5 web application with only .net core components, how can i run it on a Chromebook as a standalone application.
srivatsa6065
1

votes
1

answer
264

Views

Mvc6 versioned api actions with custom constraints

I'm making a versioned api with mvc6 and to do that I want to be able to specify for an action on which api version it should work. My api route is: /api/{version}/... and so I want at a certain action to inspect the version route value and to see if this action is available for that version. I want...
mrahhal
1

votes
2

answer
1.8k

Views

.NET Core Authorize attribute with external JWT authentication microservice?

So I'm just having a bit of trouble getting my head round the .NET Core [Authorize] attribute. I have an authentication service running (let's say authapi.com) which when provided with valid authentication details will return a JWT. When this JWT is given back to it, it will validate the JWT and re...
SamBC
1

votes
0

answer
37

Views

Early execution of IEnumerable

So I have two methods both performing iteration through IEnumerable collection. public static IEnumerable GetRange(int start, int count) { if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); var end = start + count; for (int value = start; value < end; value++) { yield return value;...
0

votes
0

answer
24

Views

Why app returns only one supported culture?

I try create language switch on my site. I've add cultures in Startup: IList supportedCultures = new List { new CultureInfo("ru"), new CultureInfo("uk"), }; var localizationOptions = new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("uk"), SupportedCultures = supportedCultu...
mykmykpet
4

votes
1

answer
90

Views

Docker build for C# core need the internet connection

I am writing in C# .NET core (VS 2017), using the build for linux containers, using docker-compose. When I build the image (or publish), there is always reference to the internet, because of nuget usage. Last error encountered (which I persume of downtime on the nuget, but no matter - any downtime...
Eitan
1

votes
1

answer
37

Views

Entity framework core can allow to specify two different length for column one for database and other for modal.validation?

Entity framework core can allow to specify two different length of column one for database and other for modal.validation?
chintan310
1

votes
1

answer
864

Views

How to get dependency injection working with IAsyncAuthorizationFilter in ASP.NET Core

I have implemented the IAsyncAuthorizationFilter interface to a class; in addition, that class is derived from Attribute, so that I can mark controller classes and action methods using it. This works so far; the Task OnAuthorizationAsync(AuthorizationFilterContext context) method is called before th...
Matze
0

votes
0

answer
24

Views

Inherit from generic class in C#

I have .net core 2.1 project. And my repository classes like below. But because of MyDbContext constructor has parameter, I'm getting error like below. When I remove JwtHelper parametrer, it is working perfectly. But, I need adding JwtHelper in MyDbContext.cs for logging auditings. How can I achieve...
Hasan Ozdemir
1

votes
3

answer
2.1k

Views

How to MSDeploy an ASP.NET Core app from command line? (csproj not project.json)

Can ASP.NET Core apps be deployed via msdeploy.exe and a .pubxml definition similar to what was possible for pre-.NET Core? This is the command that I've used previously: msbuild myproj.csproj /p:DeployOnBuild=true /p:PublishProfile=. If not, what is the preferred way to deploy an ASP.NET Core ap...
JTW
0

votes
1

answer
52

Views

C# Should Model Class Members be Public or Private [on hold]

Should most C# class members be set to private majority of the time, only in case I want other classes to modify them (then I will make them public)? I see most tutorials make all the class members public. I am beginning to think this may be bad practice. Would like to understand general software...
GregThomas582
0

votes
0

answer
9

Views

Should AutoMapper be used to Map from ViewModel back into Model?

Should AutoMapper be used to take data from ViewModel and save back into a database model? I know the opposite practice is good software practice: to have Automapper to extract database models, and place them in Viewmodels for front end web applications. I was reading this general article here: The...
GregThomas582
1

votes
2

answer
834

Views

listing all blobs in container

I am trying to create a function for all blobs in a container. I took the help How to get hold of all the blobs in a Blob container which has sub directories levels(n levels)?, which seems to use an overload that doesn't exist any more. I had added default values into the additional fields prefix a...
Neville Nazerane
1

votes
1

answer
868

Views

ASP.Net Core MVC UseExceptionHandler results in blank page

Building an ASP.Net Core (V2) MVC Site. We are using API Versions for this. The site has controllers delivering MVC Razor Views as well as API-style Json responses. I am trying to use the UseExceptionHandler() method, as shown below. When i hit an exception in one of my actions, the action gets ex...
Darren
0

votes
2

answer
14

Views

How to implement dependency injection of db context

I'm trying to adapt this tutorial on how to make a shopping cart in asp.net core mvc but I'm having trouble with the db context. I get the following error: Error CS7036 There is no argument given that corresponds to the required formal parameter 'options' of 'StoreContext.StoreContext(DbContextOpt...
mpho
1

votes
2

answer
2.2k

Views

ASP.Net MVC Core 2 - Area Routing

I'm trying to implement an Area for Administrators within my ASP.Net MVC Core 2 application. I have configured the route for the area as follows: // Default route app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Admin area route ap...
weblar83
1

votes
1

answer
988

Views

EF core not creating tables on migrate method

Hey I just started using EF core and everything works fine. I call the the context.Database.Migrate() method and it creates a database. But even though my context object has a DBSet, it doesn't create any tables except for the migration history. Can anyone help me with this issue?
Jajan
1

votes
1

answer
277

Views

Disable .AspNetCore.Antiforgery Cookie

Is there any way to prevent the .AspNetCore.Antiforgery Cookie from being created in Asp.Net Core 2? From my understanding services.addmvc internally calls AddAntiforgery and I cannot seem to find any way to prevent this? The reason why this is important is because I cannot set any cookies before th...
Kamelen
1

votes
2

answer
338

Views

ASP.NET Core 2 with EventFlow configuration

EventFlow have avery limited example on how to configure on dotnetcore which is based on dotnet core 1 and things changed a little but in dotnet core 2 Is there a way to use EventFlow configuration without Autofac? There is discussion about here and the last comments are about the same thing I am as...
ppumkin
1

votes
2

answer
779

Views

Antiforgery cookie in ASP.NET Core 2.0

I've been trying to understand exactly how the antiforgery works. What confuses me are the cookies which are created. To my understanding, you include the antiforgery token in your form and then you validate for that token when a request is made. This way if a third party websites posts to your webs...
Bojan
1

votes
2

answer
336

Views

.NET Core: How can I set the connection string?

I am trying to use Blazor's CRUD functions and following some article to do this. In the article, there is a part that I should put my connection in context file, but it doesn't say how to set the connection string. I put this code line in launchSettings.json: { "ConnectionStrings": { "UserDatabase"...
winnervswinner
1

votes
1

answer
603

Views

How to pass an array of int in ASP.NET Core Web API

I have this Web API method: [Route("api/[controller]")] [ApiController] public class SubjectsController : ControllerBase { [HttpGet("children")] public IActionResult GetAllFromChildren([FromQuery]int[] childrenIds) { // omitted for brevity } } I'm trying to call this via Ajax passing in an query str...
g_b
1

votes
1

answer
139

Views

.NET Core with Angular : How do I configure IIS for URL Rewriting in HTML5 mode?

I have built an angular 6 application with .Net core 2.1 and deployed to azure server on IIS web server. The routing is working fine on localhost when refresh, but not working on azure server. I checked angular deployment guideline and added following code in web.config file Now, I got into new prob...
Abhishek
0

votes
0

answer
19

Views

Why is my .net core API cancelling requests?

I have a an aync method that is looped: private Task GetResponseMessage(Region region, DateTime startDate, DateTime endDate) { var longLatString = $"q={region.LongLat.Lat},{region.LongLat.Long}"; var startDateString = $"{startDateQueryParam}={ConvertDateTimeToApixuQueryString(startDate)}"; var endDa...
Craig
0

votes
0

answer
7

Views

how can i add a third attribute to my user-role table?

we use the user-role based for authorization in our project. we need to add an attribute to our table (user role table),which results in the user having the role when that attribute established. for example we want to say user A in location X has a special role but same user in location Y has anothe...
Hanieh Rezayi
1

votes
1

answer
79

Views

How to implement an IObservable

I want to be able to use a Queue as an Observable and i do not know how to create it. I want it to be able to push data whenever someone calls Enqueue. class Producer:IObservable { private object @lock = new object(); private Queue queue = new Queue(); List observers = new List(); public Producer()...
Bercovici Adrian
1

votes
1

answer
41

Views

Where is AddConfigurationStore and AddOperationalStore in IdentityServer4 v2.3.2

So I create a project based on quickstart of identityserver.io, and I did everything according to tutorial. But I don't have AddConfigurationStore AddOperationalStore on services.AddIdentityServer Can anybody help me ? It is worth mentioning that they are available in IdentityServer4 v2.2.0 and i...
jsDevia
0

votes
0

answer
7

Views

Obtaining an IEnumerable from HttpPost

I am trying to create an IEnumerable from an HttpPost request. The JSON in the body reads as follows: [{"id":15496,"order":0},{"id":15500,"order":1},{"id":15503,"order":2}] The post request is like so: [HttpPost("[action]")] public IActionResult SendReorderRows([FromBody] IEnumerable rows){ foreach...
anesthetic
0

votes
0

answer
5

Views

VSTS task error when run integration tests in .Net Core 2.1

I am running API e2e tests in VSTS 2017 CD tasks and getting below error at the task (vsTest - End2End Tests) Unable to find d:\a\r1\a\Project\e2e\bin\Release\netcoreapp2.1\testhost.dll. Please publish your test project and retry. Unable to find d:\a\r1\a\Project\e2e\obj\Release\netcoreapp2.1\Projec...
SMPH
0

votes
0

answer
5

Views

How to enable facebook authentication in Core .NET 2.2 project?

I have a project written using C# on the top of Asp.NET Core 2.2. I am using the built-in Identity to enable accounts authentication. I am now trying to add integration to enable Facebook authentication. I followed the documentation to create an app on Facebook and then enable it on my site. Howeve...
Mike A
0

votes
0

answer
11

Views

ASP Net Core How Should I Configure Multiple Services which May Depend on Reusing Same Settings

At our company we use a BaseSettings, this contains log in credentials. It is normally received through the Environment variables so I am creating a method that allows everyone to register this object their own way, as well. Another service will reuse these credentials in making basic auth http call...
christopher clark
0

votes
1

answer
23

Views

Why am I getting an OPTIONS request when I enabled CORS in Web API?

I have a project with Angular Framework and Asp.net Core. In my ConfigureServices I have bellow code: services.AddCors(options => { options.AddPolicy( "CorsPolicy", builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); And un Configure as follow: app.UseC...
Saeid Mirzaei

View additional questions