Pass and read query parameters between pages with React Router
In this post we are going to see how you can register a new route in your React application and then pass information with the help of query parameters from one subpage to another.
Let us suppose the following scenario. You have page that contains a list of products with some basic information. You want to be able to click on an item of this list and navigate to a details-page, where the user can find more details about a specific product.
The following code examples are written in TypeScript. Visual Studio provides a great starting template for your React projects. I used the 4th generation of the React Router
First we need two routes for the scenario we just mentioned. The first route loads all the products, with only a limited information for each of them, from our backend and the second one loads the all the details to one product:
Manage configuration in .NET Core web projects with IOptions
Every application out there needs to read some configuration written from the programmers in order to perform critical tasks and function correctly. Examples of configuration can be the connection string to your SQL database or a boolean flag which decides if a feature will be available to your customers or not.
.NET Core gives us a way to store our configuration in a json file and access its properties programmatically.
This way of coding gives us the advantage of not having to redeploy our application, every time we update a value in our configuration (in our case the json file). We simply have to recycle the application pool that hosts our application and we are set.
Fix the project.assets.json not found error with MSBuild
While I was developing a .NET Core web application and wanted to automate the build process in VSTS, I got the following error, when I was triggering the build:
Error: Assets file ...\project.assets.json not found. Run a NuGet package restore to generate this file. Process 'msbuild.exe' exited with code 1.
The issue here is that needed .NET Core files are missing, when we start build our application. I solved this problem by defined an extra initial step in my build process.
Custom .NET attribute for mapping HTML table columns to DB columns
Consider you have to implement the following requirement:
We have an MVC .NET web application and a view with an HTML table and multiple columns. We want to mark some of these columns as searchable, so that we can search their values when we use the search field.
We host our data in a relational database, we get the structure of the DB table as it is. We use Entity Framework and we need to “map” the DB columns to their equivalent UI columns, so that the search works correctly.