Gipper
Easiest and simplest way to insert a Microsoft SQL Server DB into an app saving data in csv files?
I got a solution with several projects, most of them are console applications, one is a gRPC server. I'm currently saving data in a sequence of csv files and I would like to do the same in a simple database with as many tables as I have csv files (about 6/7 of them). What would be the best way to inject a database in it? I say MSSQL Server only because that's the one I got setup on my system, could be another one hypothetically. So long as it's quick and easy π
20 replies
Can I set up an integration testing environment with no app available and no code? If so, how?
Right now I have a test solution set up for ASP.NET and I can't launch it because it says WebServer failed to listen on port port_number. I am trying to use XUnit now:
I thought that WebApplicationFactory should have generated a web server for testing, but it's not doing so. I need it so I can debug this code, if I can.
78 replies
Help implementing multithreading in a distributed system, please?
I got a distributed system, meaning one solution that's a server and two which are clients. The objective is to use threads so that more than one client can communicate over TCP with the server simultaneously. I was told that I need to make it so there is some kind of code that makes it so different clients connect through different ports or the communication won't go well, but I really don't know. Any help you can give me? I know this isn't much to go on, but I'm trying to figure it out myself and feel free to ask questions and I'll do my best to answer.
53 replies
Help me sort out perhaps badly done folder/solution structure so I can add a shared Class Library
Ok, so I have two solutions which must be separate so I can execute them both at the same time so they will communicate (it includes TCP communication between them). They are both inside their own folder (called "Servidor" and "Cliente1") and both these folders are in turn inside a unifying folder called "TP1Code". Here's the output for the root folder of this project from the command line which may be enlightening (truncated for simplicity):
The important folders here are TP1Code itself, Servidor and Cliente1. What I want to do is add some code (only methods really) which is viewed and usable from within Servidor and Cliente1. Perhaps in the form of a Class Library?? Help?
60 replies
How to find relative file path for file inside of project?
Dealing with a C# console application, I have a folder inside the project named Files and inside that folder I have a file
Servicos_A.csv
. I want to get a relative path to that file for File I/O. My concern with using absolute path is that when I push it to github it won't work in my colleague's computer cause obviously his filesystem will be different from mine. How can I get to that path? I already searched it and asked generative AIs but it won't work, mostly because using the string assemblyDirectory = AppDomain.CurrentDomain.BaseDirectory
utility for a part of the path seems to add some unnecessary and non-existing directories into the path for some reason.2 replies
Advice on how to correctly integrate more complex Javascript code
Hey,
I've developed an ASP.NET app before, but that one was pretty much all about the backend and the database. This next one I'm about to begin on will be almost the opposite, with much more complex frontend, particularly when it comes to Javascript code. Any advice on how to do it differently so to integrate everything properly and avoiding mistakes?
6 replies
Best way to do this OOP-wise???
Ok, so this is not the actual program but for the sake of brevity I'll give you an equivalent one:
Right now what I'm doing is:
and just accessing the data through the argument passed in to the constructor and I'm only inheriting so I can access the private protected field in BaseClass. Is there a better way of doing this (i.e. two classes derived from the same base sharing the values of the vars in the baseObj)? Should I just make the field public and not inherit?
24 replies
How to pass variable from one View to another View in link?
Ok, so I have this code in my view:
as you can see, in this view I am including a link to another view, I loop through a collection of objects and would like to pass the value of one of the fields of that object (Nome_grupo) to the view being linked to. I am doing it in the Razor syntax way because it seemed simpler, but I am open to any other way as this one has proved a bit wonky.
26 replies
How to use UserManager in my controller?
What the title says, what I'm doing currently:
But Visual Studio doesn't recognize the UserManager<IdentityUser> type:
'UserManager<>' is an ambiguous reference between 'Microsoft.AspNet.Identity.UserManager<TUser>' and 'Microsoft.AspNetCore.Identity.UserManager<TUser>'
When I change it to private Microsoft.AspNet.Identity.UserManager<IdentityUser> _userManager;
I get this error:
'Microsoft.AspNetCore.Identity.IdentityUser' cannot be used as type parameter 'TUser' in the generic type or method 'UserManager<TUser>'. There is no implicit reference conversion from 'Microsoft.AspNetCore.Identity.IdentityUser' to 'Microsoft.AspNet.Identity.IUser<string>'.27 replies
How do I take text from input element of a form and put it in AspNetUsers table properly?
I'm passing it from view to controller action through parameters, if that's relevant. This input element has to have the attribute
type="password"
btw (it is a password) and I would like to be able to hash the text input in it like the system does and put it into AspNetUsers and also take what's already there and unhash it. I'm doing this cause I want to give the user a way to change their current password to a new one, if there is a better way I'm open to suggestions.13 replies
In an ASP.NET application, what is the way to in the view to check if user authenticated and roles?
I mean assuming you are using Asp.NET Identity resources and you have already scaffolded identity. Is it through HTTPContext? I know how to do it with [Authorize] in the controller, but that would require creating separate views for authenticated and non-authenticated viewers right? Is there an easier way through something like:
8 replies
ASP.NET How to create button to view under another controller?
What the title says. From a view under the Publicacoes controller I want to call another view under the Grupos controller. Currently I have this:
But it still says page can't be found. I have also tried:
Also, to no effect. Help?
10 replies
β
I can't do migrations now...
when I do
add-migration nullableForeignsOnPublicacao
I get:
So I tried Enable-Migrations
, right? I got:
Which I partially understand cause it wants a class inherint fro DbContext, but my context inherits from IdentityDbContext
. What should I do?11 replies
Big problem transfering ASP.NET app from one environment to another
What the title says, I have a desktop computer at home where I do most of my development work and I built an ASP.NET app with EntityFramework and MSSQLServer. In that computer it works fine, problem is I now need to get the app to my laptop and make it work but I'm getting all kinds of problems. I'm pretty sure there's an inconsistency or several between the two databases (the one at home and the one in the laptop). But now when I do update-database it doesn't go through because either I get the error message of EFCore version being wrong or because the project can't build (but the project can't build because I can't apply the migrations and update the database). I'm pretty sure the code itself is exactly equal as I pushed it to github from home and now pulled it down on the laptop. What should I do?
86 replies
Edit view not editing the Db entry but instead creating new one
What the title says, when I hit the submit button on the Edit view of my Utilizador model class, it goes to the HTTPPost Edit method in the controller and triggers these lines:
And instead of updating the relevant table row, it simply creates and inserts a new one with the new UserName I passed in through the view.
The commented out code was something I added to try and force it to be the utilizador object I want it to be (for when the update method is called), but when I uncomment and use the code it simply does not add anything.
26 replies
How to assign roles to already created Users in ASP.NET Identity?
In ASP.NET I am trying to attribute Roles to specific users in my Database, I already have the users and the roles created in the AspNetUsers and AspNetRoles, but now I would like to attribute each to the other as I wish. Is it "safe" to do so manually, through the SQL Server Object Explorer? Will that work with the Authorize DataAnnotations later? If not what should I do?
20 replies
ASP.NET Problem with emailSender in Register Page
Hi, so I did something and now when I go to my Register page (that I got when I create the project with the "Individual Accounts" authentication option), I get this exception:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UI.Services.IEmailSender' while attempting to activate 'Proj_Name.Areas.Identity.Pages.Account.RegisterModel'.
I've tried to try to comment ou any reference to emailSender in the entire solution, doing .AddDefaultUI() in my services config, here is that config code btw:
I should say that I don't have an actual emailSender implement nor desire or resources to implement it. I don't actually need to have email confirmation of accounts, I was happy with what it did before which was just show the text page pretending there was an email confirmation feature when there wasn't.14 replies