In this example, we have a database of tours with id, name, price, and other information. We would like to pull just the name and the price of the tour using a javascript fetch to a site hosting the razor pages. We will use the index page on the server site and assume it has […]
Excluding files and folders from your published .Net Core web project
You can exclude files or folders from your published .Net Core project by editing your project file. In Visual Studio, click on the project to open the projectName.csproj file. To exclude the file wwwroot\json\example.json, add the following. <ItemGroup> <Content Update="wwwroot\json\example.json" CopyToPublishDirectory="Never" /> </ItemGroup> To exclude all json files in that folder, add: <ItemGroup> […]
Making a Google map fit in a container
As a developer, adding a Google Map to a responsive page can be difficult because both the minimum width and minimum height have to be specified to make the map display. The best solution is to use “vw” units. 10vw will resolve to 10% of the current viewport width. For example : .themap {min-height: 120vw;min-width: […]
React example of forcing text to wrap under a photo
It can be difficult to get text to wrap under a photo, especially if the photo and text are in a flex box that just gets wider for longer text and you don’t know in advance how wide the photo will be. You want the flex box to stay the width of the photo. However, […]
Using the UserManager service in .net core
If you have used a template to set up razor pages with authentication, you may need to address the UserManager service directly. Injecting the service in the model. In this first example, we inject the UserManager service using the constructor of the Razor Page Model. We assign it to a private field _userManager. Then we […]