You can use javascript to resize a photo before posting to entity framework. The following html is included in a form with the id “formdata” and adds bootstrap for formatting. Form Html <div class="form-group"> <label asp-for="Photo" class="control-label"></label> <label class="control-label">Upload a photo</label> <div class="col-md-10"> <input type="file" name="Upload" id="Upload" onchange="loadImageFile();"> </div> <div> <img id="my_photo" src="@src"> </div> […]
Category: C# examples
C# Examples
Using the .net core anchor tag helper with Razor Pages and areas
With Razor Pages, the anchor tag helper is used somewhat differently than with MVC. A typical anchor tag helper for MVC is: <a asp-controller="Home" asp-action="Products">Our Products</a> In this case, you specify the controller as the Home controller and the handler method in the controller as “Products”. Razor Page Model In the case of a Razor […]
Preview a photo before upload in a Razor Page
When you upload a photo to your website, you want to see a preview before you click “save”. This discusses a simple way to temporarily upload a photo with ajax so as to make a seamless process that does not require your web page to be refreshed. You can also preview your photo without temporarily […]
Endpoint routing in .net core 3.1
The routing process has changed in newer versions of .net core MVC. You can route either with attribute routing or with conventional routing. However. it can be confusing if you use both. In this example, I set up examples of both types. Example: Routing a privacy statement This example is to direct to a privacy […]
HTTPS redirection problem with IOS and .net core 2.1
When working with a .net core 2.1 site, I discovered that HTTPS redirection was working with browsers on Windows computers, but not on IOS machines. This behavior can be difficult to detect if your browser is pulling the URL from its cache. The problem existed for both Chrome, Firefox, and Safari on IOS. Redirection code […]