Base solution for your next web application

Activities of "cyklussoftware"

I am running ASP.NET Core + jQuery v5.5.0 with .NET Core 2.1. The project was set up with nothing changed except connection strings (I am testing building / deploying to Docker). I am using Docker Toolbox on Windows Server 2008 R2.

My Dockerfile:

FROM microsoft/dotnet:2.1-aspnetcore-runtime

WORKDIR /app
COPY . .

ENTRYPOINT ["dotnet", "MyCompany.MyApp.Web.Mvc.dll"]

My docker-compose.yml

version: "3"
services:
    mvc:
        image: continuoustestingmvc
        environment:
            - ASPNETCORE_ENVIRONMENT=Staging
        deploy:
            replicas: 5
            restart_policy:
                condition: on-failure
        ports:
            - "9903:80"
        volumes:
            - "/c/Users/aspnetcore_logs/:/app/App_Data/Logs"
        networks:
            - webnet
networks:
    webnet:

I open my web browser and I can connect to the website running in the Docker container. The page loads with no errors. When I click "Change tenant", the user friendly "Error! An internal error occurred during your request!" dialog pops up with a loading indicator. It never goes away.

At the same time, the following error appears in the Logs:

Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted. ---> System.Security.Cryptography.CryptographicException: The key {f38bd4e9-c084-4734-98bf-f029e03bfa32} was not found in the key ring.

When I run the application on my local machine using ASPNETCORE_ENVIRONMENT=Staging and "dotnet MyCompany.MyApp.Web.Mvc.dll", everything works fine. The problem is only in Docker.

I'm not sure where this problem originates from. Is it an issue with the .NET Core 2.1 Docker Image? Or was it fixed in ASP.NET Zero v5.6?

I noticed that there is now a second button on the Download page for ASP.NET Zero. The button that had always been there before said "Download" but now there is also a "Download Test Project" button. What is the difference? Are the rules for downloading projects with Demo and Test in the name still the same? Or does the Download button register that project as your "real" project regardless of the contents of the project name?

I am using the ASP.NET Core + jQuery v5.4.1 project.

I have been using the included AppService Unit Tests to test my custom AppServices and helper classes. This is great for verifying that my logic is sound at a low level.

That said, I have found that it is helpful to test the entire application from top to bottom. I have found that some of the edits I make to generated Javascript files and/or MVC Controllers break the application while my AppServices run just fine (failures are due to incorrect Dto mappings, etc). I have been doing this "top to bottom" UI testing manually so far.

I have been doing some reading, and it is easy enough to run the ASP.NET Core project on my local machine and run a Test Project that has Selenium WebDriver tests implemented. This would automate my UI test process nicely. The only problem is that running the ASP.NET Core project from command line still instructs it to use the Default connection string, which is a SQL Server LocalDB instance. To automate tests I would need to delete the LocalDB, re-create the LocalDB, and then run the Migrator before testing again. This is long and annoying.

I was wondering if anyone here might have any ideas on how to do an "in-memory" temporary database (like the one implemented for the Unit Tests), but for Selenium UI tests. Any ideas (or alternative approaches) are appreciated.

Answer

I know about the GET request header called "Abp.TenantId", but because I want to return an ICS file using the URL ONLY and NOT through a GET request, I am having trouble.

I could create an [AllowAnonymous] MVC Controller method that takes in the tenantId as a parameter. The method can create and execute a new GET request with the Abp.TenantId header set. This will give me access to the AppService and its repositories. Once the [AllowAnonymous] MVC Controller method has the JSON data from the AppService's response, I can parse it and return the file.

Is there a better way to do this?

Answer

Right. I see AllowAnonymous for MVC controllers and AbpAllowAnonymous for AppService methods, but how do I access a specific repository without having a logged in user? Is there any build-in system for this? Or will it need to be a custom system like: access host DB, look for tenant DB based on URL parameter, then access tenant DB?

Question

I am using ASP.NET Core + jQuery v5.3.

I am looking at creating a public-facing API so that calendar services like Google Calendar or Outlook can request an ICS representation of a set of Event entities from our DB.

I will be generating the individual URLs for accessing the API within the application, so we will know the user's ID and the tenant's ID. We can embed this information into the URL and the API will know what to access.

The question ultimately becomes, with ASP.NET Zero / ASP.NET Boilerplate, how would I create an API that DOESN'T require the user to log in? Would I just use the normal ASP.NET Core way or is there a better way?

Thanks!

I am using ASP.NET Core + jQuery v5.3

The following is a snippet from the Index.js of my GeneralEvent entity (generated by RAD Tool). The snippet is part of the DataTable() function. Specifically the "items" of the "rowAction" of the "columnDefs".

items: [
	{
		text: app.localize('View'),
		action: function (data) {
			_viewGeneralEventModal.open({ data: data.record });
		}
	},
	{
		text: app.localize('Edit'),
		visible: function (data) {
			var eventObject = data.record.generalEvent;

			abp.services.app.generalEvents.hasPermissionForEntity(eventObject)
				.done(function (result) {
					var hasPermission = result;
					console.log(hasPermission);
					//return result; // I would like to return this value. This obviously won't work
				});

			//return _permissions.edit; // original code
		},
		action: function (data) {
			_createOrEditModal.open({ id: data.record.generalEvent.id });
		}
	},

OK, so hopefully you know what I'm talking about now.

I am making a sort of custom permissions system that is based on OrganizationUnits. Basically, a user can only see the Create/Edit menu option in the RowAction dropdown if he has belongs to the OrganizationUnit of the Event.

I know the "visible" attribute is set using the anonymous function. How would I return a value from my app service? I know what I have above doesn't work because it's asynchronous, but it shows what I'm trying to do.

I guess my question becomes this: How would I set the "visible" property of the RowAction dropdown once my data has been calculated in my AppService?

Thanks!

Alright, sorry for the large number of posts, but I got it to work. Turns out the checkbox was returning the value of "on/off" instead of "true/false" which threw everything off.

In my _CreateModal I added the 'value' attribute to the checkbox and set 'value="true"'. Setting the value to true doesn't set the checkbox to checked/unchecked, but I guess it triggers it to return true/false instead of on/off.

Then in my _EditModal, I added an @Html.EditorFor(x => x.IsOrganizer). Now the checkbox is properly checked and unchecked and returns the proper true/false value.

Turns out this is only a problem if the CheckBox is checked. If it is unchecked, the form saves correctly.

Great! Thanks for the detailed answer.

I am getting an error when trying to create a new OrganizationUnit with the _CreateModal.cshtml (with my added check-box)

The error says "Your request is not valid! The following errors were detected during validation. -"

Is there some javascript file that I need to change?

Showing 21 to 30 of 42 entries