James Flower

.NET Developer working on the web and cloud

Tag: asp.net

There are 13 posts with the "asp.net" tag.

Star Trek or Star Wars – Binary Classification using ML.NET

Posted on
4 min read

I have been looking for an opportunity to try out machine learning and recently had a change. Given my background with ASP.NET, using ML.NET seemed the clear choice as I am already familiar with C# and the .NET ecosystem. To try out ML.NET, I decided to make a binary classifier which would accept a piece of text and decide if the text is most likely to be related to Star Trek or Star Wars. Not that I am saying one is better (or worse) than the other. Finding the Data The first step with any

Read more...

Using Azure SignalR Service in Static Web Apps (SWA) Managed Functions

Posted on
4 min read

I recently migrated my YouTube Remote project from ASP.NET 4 to use serverless computing, such as Azure SignalR Service and Azure Functions with Static Web Apps. This aim of the YouTube Remote is to have a “display” which shows a YouTube video, and a “remote” to have play and pause controls. The remote could be a different browser window, or an entirely different device such as a mobile phone. In the ASP.NET 4 Web App version of the project, all the communication between the display and remote

Read more...

Setup Gitpod for a .NET 6+ Web App

Posted on
2 min read

Gitpod is a service which provides development environments in the cloud, but a .NET web app will need some extra configuration to make it accessible when running from a development workspace. You can use Gitpod by logging in with an account from a source control provider (such as GitHub or GitLab), and then selecting the repository you would like to use from the list of available repositories. After you have selected a repository, a new workspace is created and the files will be cl

Read more...

Supporting Multiple WS-Federation Authentication Schemes in ASP.NET Core

Posted on
5 min read

ASP.NET Core allows you to add support for multiple authentication schemes, such as social auth providers or WS-Federation. This support can be added with or without ASP.NET Identity Core. Users can then use these schemes to authenticate with your web application. While adding support for social authentication providers (such as Twitter and Facebook) is useful, sometimes applications need to support for multiple authentication schemes of the same type. An example of this would be support

Read more...

Using ngrok with IIS Express and ASP.NET Core

Posted on
3 min read

Sometimes it can be helpful to quickly make the version of a project which is running on your development machine available to others. This could be for webhook integrations, demos, or some other reason. One of the tools you can use to achieve this is ngrok. ngrok creates a secure tunnel and expose the web server running on your machine (usually IIS Express for .NET Projects if you’re working on Windows). As a result, you can give a publicly accessible URL (such as https://a1c2e3g4i5kl.n

Read more...

Changing Query String values in ASP.NET MVC

Posted on
2 min read

Recently I was trying to update a query string by adding or updating a parameter for URLs generated in a partial view. I found an excellent example for achieving this by setting route data here however this didn’t preserve current query string values in the URL. I’ve extended upon that code and updated it to include the query string values in the route data which will be appended to the query string in the generated URL (assuming the parameter key doesn’t match part of the route). p

Read more...

Disabling an ASP.NET MVC input control

Posted on
2 min read

I love ASP.NET MVC. It is a great framework to get web apps quickly built. However using the built in HtmlHelper methods on your views isn’t without its issues. An example of this is when trying to disable a HTML input control which has been built using HtmlHelper. You can add the “disabled” attribute which would be required by making use of one of the helper’s overloads however if you want to conditionally disable a control (based on your view model) it can result in your view’s code be

Read more...

Fixed/Sticky Headers on ASP.NET GridView using jQuery

Posted on
2 min read

The GridView control in ASP.NET Web Forms is an extremely useful and quick way of getting data out to the user in a nice tabular format. It does have one weak spot though and that is some of the tags it uses when doing this. Specifically, not putting the header information inside a <thead> tag. So why is this important? When you have a LOT of rows (as some do) after you’ve scrolled down the page and the table headers are out of view you can forget which column is which, especially i

Read more...

Strongly Typed Data in ASP .NET Web Forms

Posted on
3 min read

In ASP .NET Web Forms you’ve previously had to use strings to specify which properties you’d like to output when databinding, which would probably end up looking something like the following. <asp:templatefield headertext="Last Name"> <itemtemplate> <asp:literal runat="server" text="<%#: Eval("LastName") %>"> </asp:literal></itemtemplate> </asp:templatefield> In all likelihood it could probably look far less tidy if you’ve ever needed to do any formatting on values y

Read more...

Send E-mail through Microsoft Exchange using .NET

Posted on
2 min read

Recently I needed to send an e-mail using Microsoft Exchange Server from an ASP .NET Web App. My first attempt involved using the classes in the System.Net.Mail namespace however I quickly realised this wasn’t the way to be going about it as I had very little luck getting a connection to the server. After a while spent with Google I realised that there were some web services which could be used to perform tasks, these were called Exchange Web Services (EWS) and thankfully Microsoft provide a m

Read more...

Using a RequiredFieldValidator on a DropDownList in ASP .NET

Posted on
2 min read

In most applications today drop-down lists default to a “Please select..” option with some form of validation to ensure the user makes their own selection. In ASP .NET web forms this frequently results in a drop-down list being created using code similar to that displayed below. <asp:DropDownList ID="ddlOptions" AppendDataBoundItems="true" runat="server"> <asp:ListItem Text="Please select an option..." Value="-1" /> </asp:DropDownList> We can add an ASP .NET RequiredFie

Read more...

How to allow HTML content in ASP .NET MVC

Posted on
1 min read

Sometimes in web development, you need to provide an easy-to-use editor for non-technical users to input or change content where extra styling is required such as making text bold or italic. However unless you use (or code yourself) an editor which uses some form of BBCode you’re going to come across the following error message if you’re using ASP .NET. I have seen various “fixes” to this suggested, the most frequent being turning off request validation entirely. While this will

Read more...

ASP .NET AJAX Control Toolkit Reorder List control and LINQ

Posted on
2 min read

The ASP .NET AJAX Toolkit is quite a useful and yet under-used set of controls. However they can also quickly lead to bizarre issues and worse performance than normal if they are not properly understood or used correctly. This issue is compounded when you take into consideration that quite a few of the controls included have a number of fairly unique bugs in them. An instance of this is in the Reorder List control which is intended to allow a user to re-order a list of items by simple dr

Read more...