Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

WebLog Posts in Category ASP.NET

ASP.NET (324) .NET (178) Windows (77) JavaScript (72) jQuery (61) Visual Studio (54) IIS (48) Csharp (47) WPF (47) HTML (46) AJAX (45) ASP.NET (33) Localization (32) LINQ (30) WCF (28) MVC (26) Personal (25) Security (23) HTML5 (23) FoxPro (22) CSS (21) C# (20) Angular (20) Web Services (19) Web Api (16) COM (16) ADO.NET (15) Vista (11) XML (11) Sql Server (10) HTTP (10) IIS7 (10) Markdown (9) WebView (9) Microsoft AJAX (8) IIS7 (7) West Wind Ajax Toolkit (7) Web Connection (7) Entity Framework (6) Html Help Builder (5) Markdown Monster (5) Live Writer (5) Internet Explorer (5) C++ (5) ASPNET5 (5) Web (5) OWIN (5) SignalR (5) Software Development (5) NuGet (5) Mobile (5) WinForms (5) Westwind.Globalization (4) Source Control (4) Silverlight (4) Cordova (4) Conferences (3) DataBinding (3) ASP.NET Core (3) Help Builder (3) ISV (3) LetsEncrypt (3) Networking (3) Office (3) Opinion (3) Razor (3) Web Browser Control (3) WebLog (3) Web Development (2) Visual Studio Code (2) Tools (2) Speaking (2) RegEx (2) RSS (2) Linux (2) Installation (2) Bugs (2) Help (2) Dotnet (2) .NET Standard (2) Addins (2) Deployment (2) Authentication (2) ASP.NET vNext (2) ADO.NET (1) Chocolatey (1) Blazor (1) Blogging (1) Desktop (1) Control Development (1) Credit Card Processing (1) Cross-Platform (1) .NET ASP.NET Windows (1) Security (1) Visual Studio (1) ASP.NET IIS (1) ASP.NET Markdown (1) AI (1) Angular JavaScript (1) Dynamic Types (1) Email (1) CSharp Dotnet (1) Git (1) Graphics (1) Hardware (1) FireFox (1) Flexbox (1) IOS (1) JSON (1) Migration (1) rxJs (1) SEO (1) RazorPages (1) Musings (1) Travel (1) Typescript (1) Testing (1) Threading (1) VS Code (1) Web Deployment Projects (1) Web Design (1) Web Assembly (1) WebSockets (1) WebSurge (1) WebBrowser (1) WebDeploy (1) WFH (1) Windows-Terminal (1) Windsurfing (1) WPF Windows (1) WSL (1) wwHoverPanel (1)

Comparing Raw ASP.NET Request Throughput across Versions

When I set up a new machine I usually use a small ASP.NET test project to get a feel of performance of the machine and when that happens I also take a moment to compare performance across recent versions of .NET to see how things are improving - and improved they have. Both due to the new hardware I'm using but also ASP.NET continues to bump up performance in every new version that comes out. In this post I describe a simple project with minimal do nothing requests to test the ASP,.NET pipeline locally and how to test these request as well as discussing the results.

Reading Raw ASP.NET Request.Body Multiple Times

Some time ago I wrote about accessing raw request body content in ASP.NET Core which ended up being one of the most popular posts on this blog. But I failed to mention one major caveat: By default Request.Body can only be read once. In this post I discuss why frequently when you need raw Request.Body access you actually need to read the body more than once, and you can enable that functionality and deal with the caveats of doing so.

Embedding a minimal ASP.NET Web Server into a Desktop Application

Did you ever need to embed a Web Server into a non-Web application? In this post I describe how you can use host ASP.NET in a non-Web application and specifically in a WPF desktop app. What do you need, how is it different and some of the issues that you need to consider if you want to use ASP.NET in your non-Web applications.

IIS Error 500.19 with ASP.NET Core Application

Running on IIS locally is pretty rare, but if for some odd reason you decide to run IIS locally on your dev machine you might find yourself getting a 500.19 error which relates to an issue in the web.config configuration. The solution is simple enough: Make sure the ASP.NET Core Hosting Module is installed. In this post I describe in more detail what the problem is and why you need a seemingly superfluous extra install to get IIS and ASP.NET Core to cooperate on local dev machine.

Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET

ASP.NET Core doesn't have a Server.MapPath() method as classic ASP.NET had, and getting at the root path in Core is a little bit more involved than in those older versions. In this post I describe how to find the application Content and Web root folders and describe a MapPath() helper that simulates the old behavior.

Implementing Two-Factor Auth using an Authenticator App in ASP.NET

Two factor authentication using Authenticator apps is getting more popular. One advantage of Authenticator 2FA is that you don't need to use a service nor do users have to provide additional bits of personal information. It's easy to implement, doesn't cost anything and also very secure as it uses one-time codes that can't easily be corrupted short of physical take over of a device. In this article I describe how Authenticator based 2FA works in the context of an application without using ASP.NET Identity.

Removing the IIS Server Request Header from ASP.NET Core Apps (any version)

ASP.NET Core applications that run on IIS as InProcess output an Server name for IIS into the HTTP headers. If you want to remove the server header, you'll find that the process for IIS is different than for the internally created Kestrel header and you can't use the same approach to remove the header as with Kestrel applications. In this post I discuss why the header behaves differently in IIS and how to remove it regardless of ASP.NET version.

Avoid WebDeploy Locking Errors to IIS with Shadow Copy for ASP.NET Core Apps

If you're self-hosting ASP.NET Core applications on IIS and using WebDeploy to publish to the server, you've very likely run into the dreaded locked file problem on the server. In this post I show you how you can work around locking problems with the base WebDeploy configuration and by using a new experimental feature in ASP.NET 6.0 to Shadow Copy deploy binaries. As a bonus this post also describes setting up and using Web Deploy in some detail.

HSTS: Fix automatic re-routing of http:// to https:// on localhost in Web Browsers

If you're doing local Web develop with multiple development tools you've probably run into a problem where you end up not being able to access a local site via unsecured `http://` requests and automatically get redirected to `https://` no matter what you try. If you don't have a certificate set up for the site you may not even be able to access the site at all. Turns out this usually is due to HSTS which is a nasty little bugger of a security protocol that is applied universally to a domain even in applications that don't use HSTS. In this post I discuss how HSTS works and why it can be a problem for local development as well as how to clear out the HSTS cache or avoid using it locally.

Testing HttpRequest.Form Variables in Unit Tests for ASP.NET Core Components

Here's a quick post that shows how to create a testable HttpRequest.Form collection so you can test form variables in a unit test.

Keeping Content Out of the Publish Folder for WebDeploy

Sometimes when you publish a project to the server, you need to keep certain content that's part of your local development from publishing to the server. You can control how MSBuild publishing handles file output in a myriad of ways and it can be confusing if you don't know the exact settings you need to set for each scenario. In this post I discuss various options available include using the project item settings and the options in the pubxml file along with some commentary on when you might need this functionality.

Mapping Multiple Static File Folders in ASP.NET Core

Recently I needed to map an external folder as a 'virtual' directory in an ASP.NET Core application to include externally added content into the main Web application. ASP.NET Core's Static File Middleware provides easy mapping of a folder for static file serving, but it's not so obvious to add additional folders for static file serving. In this post I'll show you how to do this and a few other thoughts around this topic most common when physically hosting on a server.

ASP.NET Core MVC Views not Resolving Partial Views outside of the default ControllerContext

I recently ran into a problem with ASP.NET Core MVC views where rendering a Parent View in a Controller Context other than the originally designed context won't find Child Views that are referenced with no or local or relative paths. It turns out that ASP.NET Core MVC does not resolve local View paths as expected when rendering a View from a different ControllerContext instead using the current controller's context paths, rather than the view relative paths. In this post I describe why this can be a problem and several ways to work around this problem.

Back to Basics: Custom HTTP Response Header Manipulation in ASP.NET Core

HTTP Headers are a core part of the HTTP protocol and while applications rarely need to deal with them, when you need to set them - especially globally - ASP.NET Core doesn't have an obvious, built-in way to add headers to every request. In this back to basics post I describe what HTTP header, why you might set them and show how to set them as part of individual requests as well as globally for every request in your site.

Back to Basics: Rendering Razor Views to String in ASP.NET Core

Rendering a Razor View to string can be very useful to create string output from Views that you can capture and then use for things like Email confirmations or saved receipts that can be accessed 'offline' from the application. In this post I show you how to capture views to string and a few caveats you have to watch out for if you're generating self-contained HTML output to string.

Combining Bearer Token and Cookie Authentication in ASP.NET

In some situations you might need to use both Bearer Token and Cookie Authentication in a single application. In this post I look at a few scenarios where this is required and show how to configure your Authentication to let you access your site with either authentication scheme.

Back to Basics: Add an ASP.NET Runtime Information Startup Banner

In almost every .NET Core Console application I end up adding a startup banner with some basic runtime information so I can see at a glance what environment I'm running in. I also add the URLs and any other application specific information that might be useful. In this short post I show a few things I display and how I reuse this functionality since it practically goes into every application I run.

Locked Files When Publishing .NET Core Apps to IIS with WebDeploy

When using Visual Studio's Publish Web Site feature with ASP.NET Core you may get frustrating errors when publishing to already running sites as files on the server are locked and can't be updated until the site is shutdown. Turns out the default settings don't unload the application before publising, but there's a simple solution to unload before publishing and the restart the application.

LiveReloadServer - A Generic Local Static Web Server with Live Reload based on .NET

I've released v1.0 of my LiveReload Web Server which is a local static file Web server that includes support for LiveReload, plus some optional dynamic features for rendering self-contained RazorPages and Markdown content. This Dotnet Tool is fast, easy to use and includes a host of convenience features that try to make the process of working with local Web content quicker and easier.

Role based JWT Tokens in ASP.NET Core APIs

ASP.NET Core Authentication and Authorization continues to be the most filddly part of the ASP.NET Core eco system and today I ran into a problem to properly configure JWT Tokens with Roles. As I had a hard time finding the information I needed in one place and instead ended up with some outdated information, I'm writing up a post to hopefully put all the basic bits into this single post.

Watch out for .NET Core Runtime Bitness for IIS Installs

I recently ran into a snag with one of the my Windows Server installs of an upgraded .NET Core 5.0 application. It turns out I didn't install .NET Core 5.0 correctly because I made some bad assumptions of what I needed to install to run my application, even though it previously ran on .NET Core 3.1. Here's more detail on what the failure looks like and how to properly install .NET Core 5.0.

Upgrading several of my Applications and Libraries to .NET 5.0

Over the last week I spent some time upgrading several .NET Core Web applications and libraries from .NET Core 3.1 to .NET 5.0. I'm happy to say that this was always a non-event as the process went very smooth for once. In this post I'll talk about what I found and also offer some commentary why we should celebrate this update and push Microsoft to continue along this path.

Don't get burned by missing await Calls for Async Code in ASP.NET Core Middleware

I recently got burned in an upgraded ASP.NET Core server application where a missing `await` statement caused wildly inconsistent and puzzling output failures. While a simple thing to avoid, once introduced it's possible to live with this error for some time before it manifests. In this post I show a scenario where a missing `await` was causing infrequent HTTP response errors, even though the client apparently receives a valid response.

Using .NET Core Tools to Create Reusable and Shareable Tools & Apps

Dotnet Tools offer a simple way to create, publish and consume what are essentially .NET Core applications that can be published and shared using the existing NuGet infrastructure for packaging and distribution. It's y quick and easy to build tools that you can share either publicly or privately. In this article I make a case for why you might use or build a Dotnet Tool and show how create, build, publish and consume Dotnet tools as well as showing some examples of useful tools I've build and published.

Excluding Files and Folders in Visual Studio Web Site Project

I still use Web Site projects frequently for purely static Web sites that don't require a proper build process where 'DevOps' of any kind is overkill. Invariably when using Web site projects though, I end up requiring that 1 or 2 files are excluded on publishing and every time I do I spent a while trying to find the information how to do that in the `.pubxml` file. Well no more - I'm writing it down this time.

Handling SPA Fallback Paths in a Generic ASP.NET Core Server

When building ASP.NET Core backends for SPA applications one thing that you have to worry about is how to handle client side routes that end up being fired against the server through external or reloaded links. While ASp.NET Core has built-in support for this if you build a generic Web server, you might need a little more control on how to handle the Fallback routing functionality. Here's how.

Adding Additional Mime Mappings to the Static File Provider

If you're using the Static File Provider in ASP.NET Core you might need to add some additional extensions that are not handled by default. For example, if you host a Blazor site in your own application an additional mime mapping for `.dll` is required. Here how you can map extra extensions to the Static File middleware.

ASP.NET Core WebSockets and Application Lifetime Shutdown Events

WebSockets in ASP.NET Core are easy to use but due to the simple model it's easy to forget that socket requests are long lived and can linger for a long time in the background and that can cause problems when an application needs to shut down cleanly. Luckily there's an `IHostApplicationLifetime` interface available that allows hooking shutdown operations and that provides the necessary cancellation tokens to allow an WebSocket connection to be terminated in response to a shutdown event. This post shows how this works.

Content Injection with Response Rewriting in ASP.NET Core 3.x

If you're creating middleware components you might need at some point to inject content in the existing HTTP output stream in ASP.NET Core. In this post I discuss how to intercept Response output by using a customized stream, modify the data and update the final output generated, effectively providing response filtering.

Working with IWebHostEnvironment and IHostingEnvironment in dual targeted ASP.NET Core Projects

In ASP.NET Core 3.x Microsoft introduced a new `IWebHostEnvironment` to replace the obsoleted `IHostingEnvironment`. While that works for top level applications this can cause some complications for multi-targeted libraries that need to support both .NET Core 2.x and 3.x. This post describes the problems and offers a few workarounds.

ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1

Ran into a nasty little issue with a hosted ASP.NET Core 3.1 application where InProcess hosting was not working. It turns out I hit a regression bug in 3.1 that causes InProcess hosting to fail if there are certain dependencies.

FireFox, Windows Security and Kestrel on ASP.NET Core

Ran into issues today with Windows Authentication and FireFox in a ASP.NET Core application where auth was working with all browsers **except** for FireFox. Firefox would just throw up endless sequences of login dialogs or in some cases just show the default ASP.NET Core 'UnAuthenticated' dialog. Here's what this looks like and how to work around it.

Dynamically Loading Assemblies at Runtime in RazorPages

I've been working on some tools that create generic, standalone Web servers using ASP.NET Core, in various configurations. One of the versions I'm building also supports Razor Pages and while genericallly hosting Razor Pages out of a locally run folder, there are some complications that arise out of dynamic runtime compilation. In this post I look at how to dynamically load assemblies at runtime.

Windows Authentication and Account Caching on Web Browser Auto-Logins

If you're working with Windows authentication to access Windows or Active Directory groups be aware that there's a gotcha with newly added groups when users are automatically logged into the Web browser.

Serving ASP.NET Core Web Content from External Folders

ASP.NET Core makes it easy to create a new Web site, but by default the location of where the application runs and serves files from is pretty static and pinned to the startup folder of the application. In this post I discuss another usage scneario of building a generic local Web Server that can start serving files out of **any** folder.

Upgrading my AlbumViewer Sample Application to ASP.NET Core 3.0

.NET Core 3.0 is here and in this post I describe the process of updating an existing ASP.NET Core Angular API application to this latest release. For the most part the update process is very smooth with a few configuration changes required, but there are also a few gotchas that have bitten me and I'll cover those here.

Building a Live Reload Middleware Component for ASP.NET Core

In my last way I showed how to use Live Reload in ASP.NET Server side applications using a tool called BrowserSync. In this post I replace BrowserSync's functionality with a custom Live Reload Middleware component for ASP.NET Core that's more efficient and doesn't require installing and running a separate tool. I'll show how Live Reload works, and how to implement the component in some detail.

Live Reloading Server And Client Side ASP.NET Core Apps with BrowserSync

Client side live reloading is one of the most compelling features of client side JavaScript development. Instant updates of any code changes in the browser are a huge productivity booster - WYSIWYG on steroids. Unfortunately for ASP.NET Core server side code and MVC apps there aren't any comparable easy solutions. In this post I show how I use Browser Sync and `dotnet watch` in combination to provide live reloading for both server and client side changes.

Accessing RouteData in an ASP.NET Core Controller Constructor

Ran into a difficulty trying to get access to RouteData() generically outside of Controller code in ASP.NET Core. Specifically I needed to get at route data to pull out a tenant ID required to set up a DbContext with the right connection string to connect to. Getting the route data as part of the DI process in the Controller constructor proved to be challenging. In this post I describe the problem and the work around.

ASP.NET Core In Process Hosting on IIS with ASP.NET Core

In version 2.2 ASP.NET Core adds support for direct in-process hosting which improves throughput considerably using an easy mechanism that allows switching between in-process and out-of-process hosting. In this post I describe how to use in process hosting and how it works.

Don't let ASP.NET Core Console Logging Slow your App down

Today I ran into a self-inflicted problem with Console logging while playing with a toy test project. By accident I ran the application under load and Console Logging was on and performance was horrendous. In fact nearly 40x slower horrendous. Although my error, there are a few ways this can happen and it's important to understand that Console logging is very, very slow and in this post I show how this happened and why you want to be careful with Console logging in production.

Updating Westwind.AspnetCore.Markdown with Markdown from Files and URLs

In the last week I've had a need to add some additional features to my Westwind.AspnetCore.Markdown library that provide easier access to Markdown from files and urls as well as the ability to replace the default Markdown parser in the library. In this post I'll discuss some of the feature additions including some implementation notes.

Getting around Chrome POST XSS Protection

Ran into an unusual issue where Chrome is blocking user input from a TextArea that includes HTML form and input control input - on the client side. While I'm familiar with server side input validation, this is client side validation that causes the response to be rejected. Here's more info on the error and how to get around it when necessary.

Which .NET Core Runtime Download do you need?

.NET Core has a number of different runtime downloads that you can grab to install. The combinations of downloads can be a bit confusing and it depends on whether you install a development or runtime environment. In this post I describe what each download contains and what you should use it for.

Updating my AlbumViewer to ASP.NET Core 2.1 and Angular 6.0

Took some time to upgrade my AlbumViewer application to ASP.NET Core 2.1 RC and Angular 6.0. The .NET Core update was very smooth with only very minor adjustments required showing that Microsoft has smoothed out the update path significantly from the frenetic pace of past versions. The Angular update was a bit more involved primarily due to the changes in rxJS.

Creating a generic Markdown Page Handler using ASP.NET Core Middleware

I've been talking about Markdown a lot in recent blog posts and this time I'll cover a generic Markdown page handler that you just drop into any site to handle semi-static page editing more easily with Markdown from within an ASP.NET Core application. While Markdown is common fare in CMS or blog applications, it's not so apparent how to get similar generic Markdown document rendering within the context of an existing application. The middleware I describe here allows you to simply drop a markdown file into a configured folder and have it rendered into a stock template. Simple but very useful.

Getting the .NET Core Runtime Version in a Running Application

Microsoft has a long history of not providing a reasonable way of looking up the version of the runtime that is hosting your applications. .NET Core is no different and in this short post I show one way you can capture a descriptive name of the runtime executing that's suitable for displaying in your application's info page.

Creating an ASP.NET Core Markdown TagHelper and Parser

A couple of months ago I wrote about creating a WebForms based Markdown control. This time around I'll build an ASP.NET Core MVC TagHelper that performs similar functionality for embedding Markdown text into a content area of a Razor page. The component also includes easy access to a Markdown parser using the blazing fast MarkDig Markdown parser.

Accessing Configuration in .NET Core Test Projects

.NET Core provides a clean configuration system and in ASP.NET Core that code is automatically configured for you. In test and other non-Web projects however you have to manually configure the configuration provider yourself. In this post I look at a couple of ways to set up a configuration provider both using raw configuration objects or by explicitly configuring through the depedency injection system.

Easy Configuration Binding in ASP.NET Core - revisited

In this post I'm taking another look at using strongly typed configuration settings in ASP.NET Core, using a slightly simpler approach that foregoes using IOptions in favor of directly using a configuration object instance. In the process I review the various approaches as a summary for getting configuration settings into .NET types.

Dev Intersection 2017 Session Slides and Samples Posted

I've posted my Session Slides and code samples from last week's DevIntersection conference on GitHub.

.NET Core 2.0 and ASP.NET Core 2.0 are Here

After a long wait .NET Core and ASP.NET Core 2.0 are finally here. This release is a major update from Version 1.0 that brings back a ton of functionality that was originally missing in .NET Core 1.x. With closer compatibility to full framework .NET it's much easier to port existing code to .NET Core, as having a much larger API surface to use in your applications. There are many usability improvements that make it easier to get started using considerable less fanfare. In this post I describe some of what's new and what's great and also a few things that are not so great.

A few notes on creating Class Libraries for ASP.NET Core

I recently started to collect some of my ASP.NET Core utilities into a helper support library as I tend to do. In the process I ran into a few snags and I realized I was making a few non-obvious mistakes right from the start. In this post I discuss a few of the issues with dependencies and how to deal with them.

Conditional TargetFrameworks for Multi-Targeted .NET SDK Projects on Cross-Platform Builds

If you build multi-targeted .NET SDK projects on multiple platforms you're going to find out that certain targets can't be build on certain platforms. If you target NetStandard and Net45 on a Mac, Net45 is going to fail. In order to get around this you need to conditionally build per platform. Here's how.

Configuring LetsEncrypt for ASP.NET Core and IIS

LetsEncrypt makes it easy to create SSL certificates for your applications for free and lets you automate the process. When using LetsEncrypt with IIS and ASP.NET Core however a few extra steps are required to make an ASP.NET Core site work with LetsEncrypt. I show you how in this post.

Handling HTML5 Client Route Fallbacks in ASP.NET Core

HTML5 client routes work great on the client, but when deep linking into a site or pressing refresh in the browser, HTML5 client side routes have a nasty habit of turning into server HTTP requests. Requests to routes that the server is likely not configured for. In this post I look at why HTML5 client routes require server cooperation to handle and how to set them up on IIS and/or ASP.NET Core.

Multi-Targeting and Porting a .NET Library to .NET Core 2.0

I've been holding off porting any of my full frameworks to .NET Core. With the latest .NET Core 2.0 and .NET Standard 2.0 releases and their vastly larger footprints that match more closely with what we expect of the .NET Framework feature set, migrating looks a lot more appealing. In this post I describe the process of porting one of my general purpose full framework libraries to .NET Standard 2.0 and in the process also creating a multi-targeted project that compiles .NET 4.5, 4.0 and .NET Standard projects.

Bypassing IIS Error Messages in ASP.NET

IIS Error handling is the source of lots of confusion. I've been using IIS for nearly 20 years now, and figuring out the right combination of error configuration settings and code to properly serve custom error pages or error responses in API still makes fumble a few times before I get it just right. This post provides a few hints and some background on how to deal with error handling.

Upgrading to .NET Core 2.0 Preview

With the release of the first preview of .NET Core 2 and ASP.NET Core 2.0 I decided to upgrade my AlbumViewer sample application to the latest bits and preview tools. Overall the experience was pretty smooth, but I ran into a couple of breaking changes and a few tooling snags that I'll describe in this post.

IIS and ASP.NET Core Rewrite Rules for Static Files and Html 5 Routing

If you're running ASP.NET Core under Windows with IIS, you'll want to take advantage of letting IIS serve up your static content and handle your HTML 5 Client and home routes. IIS is very efficient at handling static content and content re-routing and in this post I describe how you can properly configure ASP.NET Core applications using the AspNetCoreModule and IIS Rewrite Rules

Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

The Windows Shell for Linux (WSL or Bash on Ubuntu on Windows) provides a nice way for Windows and Linux to interact without the overhead of dealing with a separate VM. Using the WSL you can now also run your .NET Core applications directly under Linux without requiring a VM or Docker. In this post I demonstrate how the shell works and how you can run your .NET and ASP.NET Core applications to test operation under Linux.

Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

I updated my AlbumViewer sample application recently to the latest versions of ASP.NET Core (1.1) and the new .csproj project as well Angular 4

More on ASP.NET Core Running under IIS

Since my last post about hosting ASP.NET Core on IIS I've gotten quite a few questions and comments in regards to working with this mixed IIS/Kestrel hosting environment. There are quite a few not so obvious arrangement in this set up and some surprising discoveries in terms of performance and segragation of feature usage between IIS and Kestrel.

Empty SoapActions in ASMX Web Services

Recently I had to deal with an ASMX Web Service that was receiving empty SoapActions from the client. ASMX doesn't like that, but luckily there's an easy work to strip out the errant Soap header.

New CODE Magazine Article: Getting down to Business with ASP.NET Core

The latest issue of CODE magazine features my `Getting down to Business with ASP.NET` Core article as the cover article. The article focuses on building an ASP.NET Core backend for an Angular 2 front application, covering all aspects of separating business and Web app logic, dealing with EF Core data access in related tables, CORS to be able to run across domains and simple authentication in a client centric REST service application. Check it out.

.NET Standard 2.0 - Making Sense of .NET Again

It's taken awhile but it seems Microsoft is finally nailing the message for .NET going forward and .NET Standard with its common API specification is a huge part in making sure that the same base library of .NET is available on all .NET platforms. In this post I look at what .NET Standard is, how it works and what some of the surrounding issues and impacts are for the .NET Eco system.

Excluding the node_modules Folder in Visual Studio WebSite Projects

If you're working on a client side project that includes an NPM folder with a large number of dependencies and you're using a WebSite Project in Visual Studio, you've probably found that this is a terrible combination out of the box. In this post I describe why this is a problem and how you can work around it with a simple hack.

Error Handling and ExceptionFilter Dependency Injection for ASP.NET Core APIs

Exception handling in API applications is important as errors - both handled and unhandled - need to be passed to clients in some way to let them display error information. ASP.NET's default error handling doesn't provide for object error results by default, but you can use an ExceptionFilter to intercept exceptions and format them yourself. In this post I look at how to create an API exception filter to create error object responses, and hook up custom logging of those errors to disk.

External Network Access to Kestrel and IIS Express in ASP.NET Core

Recently I needed to connect to my Windows based ASP.NET Core API from my Mac and in order for that to work some configuration settings are necesary so that the ASP.NET applications can serve HTTP content to the external network connection that this entails. In this post I show what you have to do to enable remote connections both using the Kestrel and IIS Express Web servers.

ASP.NET Core and CORS Gotchas

CORS is a requirement for cross domain XHR calls, and when you use Angular 2.0 default dev server and talk to an ASP.NET Core application you'll need to use CORS to get XHR to talk across the domain boundaries. Here's how to set up CORS and how to test it.

First Steps: Exploring .NET Core and ASP.NET Core

In this post I'll demonstrate how to get started with .NET Core and ASP.NET using the Command Line Tools. I'll create a few very simple projects and starting with a plain console application, show how to hook up ASP.NET, run an API and MVC app and then run the app locally on Windows and then move it over to run on the Mac. This is not meant to be your typical getting started tutorial that jumps right into Visual Studio and creating a Web project from there. Rather, the purpose of this post is to demonstrate some of the core underpinnings of how .NET Core and ASP.NET Core projects are bootstrapped to run.

ASP.NET Web Site Project Publishing and Changing ACLs

When publishing ASP.NET Web Site Projects, the project publish will overwrite server ACLs by clearing them to the inherited defaults and removing rights from common accounts. The result is that if you have custom ACLs set on the server they will be wiped by default. This occurs only on Web Site projects and in this post I remind myself of the .pubxml override setting that disables this default behavior

Upgrading to ASP.NET Core RTM from RC2

I installed and upgraded an ASP.NET Core Sample application today and while the actual project upgrade process from RC2 was relatively easy, there were a few hiccups with installation and one of the breaking changes for the RTM release. In this post I'll go over some of the things I ran into and the workarounds.

ASP.NET Core and .NET Core Overview

ASP.NET Core and .NET Core are almost here, with the RTM release scheduled for the end of this month. In this post I’m going to revisit the high level overview architecture of .NET Core and ASP.NET Core since so much has changed, to help you understand how the pieces fit together and what it means to develop on the new stack along with some personal thoughts on how I plan to approach all of this new tech in my own work.

Publishing and Running ASP.NET Core Applications with IIS

If you plan on hosting ASP.NET Core applications on IIS, you'll find that the process to get your application to run is quite different than it was with classic ASP.NET. Because ASP.NET Core applications are essentially standalone Console applications that run outside of IIS, some special tooling and new publishing tools are required to get your apps up and running on Windows Server. In this post I'll give an overview of the architecture and show you how to deploy your ASP.NET Core applications using IIS on Windows Server.

Strongly Typed Configuration Settings in ASP.NET Core

ASP.NET Core provides built-in support for using strongly typed classes to represent configuration information. The configuration system provides a flexible mechanism for using different configuration storage providers and mapping those providers to your strongly typed objects. In this post I show how to set up strongly typed resources and use them in your ASP.NET Web applications.

Using Westwind.Globalization to edit loose RESX Files

Although Westwind.Globalization is primarily aimed at Web applications, you can also use it to edit arbitrary RESX files using the Localization Administration interface that comes with the library. In this post I show how you can import RESX resources, then use the editor to manipulate RESX resources interactively, and then export the resources back out, using a local Web application on your machine.

Google AdSense for AJAX Content

I recently redesigned one of my Web sites to use dynamic page re-loading for additional page content, which broke the original AdSense ad code. In this post I'll describe how to get AdSense ads to work with AJAX loaded content by explicitly calling Googles ad code from your dynamic navigation code.

Configuring ASP.NET and IIS Request Length for POST Data

One of the most infuriating things about IIS configuration in general is how the Request length is configured in the IIS and ASP.NET. There are several places that control how much content you can send to the server and over the years this setting has changed in a number of ways. The places where it's configured is not super obvious and they can be fluid because some of these features are...

Reversing Sort Order on DOM Elements using jQuery

When creating list content in Web pages, it's often quite useful to allow users to sort or reverse the order of items displayed. Creating client side sortable lists is easy to do and in this post Rick shows an easy way to make a list reversible using jQuery.

A small jQuery Resizable Plug-in

I recently had a need for a simple resize component and couldn't find a lightweight implementation. I ended up creating a small jquery-resizable plug-in. In this post I discuss a few use cases for resizables and show the jquery-resizable plug-in, how it works and how it's implemented.

Mysteriously stubborn IIS 401.2 Errors

I ran into a nasty IIS issue yesterday that took me the better part of a day to get myself out of. It involved particularily stubborn Authentication requests from ASP.NET applications when there shouldn't have been any. It turns out the culprit was some corrupted config files - here's the why and how.

Upgrading ASP.NET 5 Projects between Beta Versions

Upgrading ASP.NET 5 projects from beta to beta has not been pretty. The beta 6 update has been one of the easier ones to work through, but still there's a process involved. In this post I describe the steps I tend to go through for each new beta release.

Using and Debugging External Source Code Packages in ASP.NET 5

ASP.NET 5 and the new DNX runtime make it very easy to include external source code based packages into your own projects. It super easy to pull a project - including Microsoft's core DNX runtime projects, from GitHub and then link it into your own projects. This is great for debugging and fixing an immediate problem that might be a show stopper for you, or makes it very easy to contribute back to an open source library. In this post I'll describe a debug scenario I ran into in my last post involving a bug in the DNX runtimes, and show how to download and link the library from Microsoft's GitHub repository, fix the bug and integrate the code into my own project.

Strongly typed AppSettings Configuration in ASP.NET 5

ASP.NET 5 features a new configuration system that includes a number of new configuration sources as well as an easy way to consume strongly typed resources. In this post I demonstrate how to use the basic features and show how you can use different configuration stores to hold configuration data.

How to manage Content in NuGet Packages?

In getting ready to put out version 2 of Westwind.Globalization I've been rearranging the NuGet package layout a few times and I'm considering further breaking out the package layout. In this post I describe some of the dilemmas I'm looking at in deciding how much abstraction is required in breaking the NuGet packages into easily usable and maintainable components with the least amount of friction.

Interactive ASP.NET Resource Linking and Editing with Westwind.Globalization

Resource linking for resource editing is a very useful feature when localizing application, making it easy to jump back and forth between content and the resources that need to be edited. Seeing resource content in context is vital to good application localization. Westwind.Globalization provides a simple HTML based resource linking mechanism and in this post I describe how it works, and how it's implemented in the Westwind.Globalization library.

Right To Left (RTL) Text Display in Angular and ASP.NET

Recently I was gently asked to add support for RTL language editing in my Westwind.Globalization library and the Web Resource Editor. The Editor supports displaying resources in all of its localized version, but it didn't respect the RTL setting for languages that required it. In this post I describe how RTL support works in browsers, how you can detect RTL support on a locale in .NET and demonstrate how I integrated basic RTL edit and display support for the Resource Editor using a custom Angular directive.

401 Response from ASP.NET Identity when linking to External Accounts

A couple of days ago I ran into an odd problem where all of my external ASP.NET Identity providers would fail to redirect to the external provider login URLs. Instead the app fired empty 401 requests without any other indication of failure. It turns out this was a misconfiguration issue, but it took a bit to track this down due to the fact that there's no error trapping and no error information. Here's more info on this edge case failure.

Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application

ASP.NET 4 provides a new Identity Authentication/Authorization framework that's very comprehensive and works reasonably well for new applications. However, if you have existing applications or use custom user management, it's not very clear how to use just the basic OWIN Authentication/Authorization layer without the full UserManager and Entity Framework implementation. In this post I describe how to use the bare minimum Identity features to hook up a custom domain model for both local and external logins in an ASP.NET MVC application.

ASP.NET MVC, Localization and Westwind.Globalization for Db Resources

Recently I've been getting a number of questions related to customers having issues with running the Westwind.Globalization Database Resource provider library under ASP.NET MVC. While the original versions of this library were definitely WebForms centric since it originated in the WebForms era, the library has had full support for ASP.NET MVC for a while. In this post I'll review how localization works in ASP.NET MVC and then demonstrate how Westwind.Globalization handles the same scenarios with database resources.

Using FontAwesome Fonts for HTML Radio Buttons and Checkboxes

Spruce up your boring checkboxes and radio buttons with custom FontAwesome symbols using a little bit of CSS. If you're tired of boring checkboxes and radio buttons, or you simply want a more consistent look of these controls across browsers and controls check out FontAwesome to provide you with customizable checks and boxes to use for selection boxes. In this post I'll show how to use pure CSS to set up FontAwesome checkboxes and radios and talk about a few gotchas I ran into along the way.

Updating Assembly Redirects with NuGet

There's little known NuGet command that allows you to re-create assembly redirects for all NuGet packages in your project or an entire solution.

A .NET QueryString and Form Data Parser

.NET is a bit short when it comes to tools that can manipulate UrlEncoded data. If you need to read, create or modify raw querystrings or form data outside of ASP.NET's System.Web context there isn't a clean way to do this and even there if you want to modify url encoded data you'll need to write some code. This article describes a UrlEncodingParser class that lets you read in raw query strings, form data or entire URLs, then lets read, add and update values and then write the values back out. Makes you wonder why that functionality doesn't exist natively somewhere in .NET, eh? Code and samples are provided.

West Wind WebSurge - an easy way to Load Test Web Applications

Recently I had a need for a load testing tool and after quite a bit of frustration to find a decent reasonably priced load testing tool, ended up giving up searching and building one instead. In this post I introduce West Wind WebSurge, an easy to use Web load testing tool that makes it easy to stress test Web applications.

Creating ASP.NET MVC Negotiated Content Results

ASP.NET MVC doesn't directly support content negotiation, but with a little bit of work it's very straight forward to implement a NegotiatedContent ActionResult that can switch its response type based on the Accept header.

Westwind Application Configuration Updates

I've recently updated my code-first, class based application configuration library with a number of features and updates. This blog post discusses some of the changes and new features of this useful library.

Auto Selecting Cultures for Localization in ASP.NET

When creating multi-language Web sites, one of the key issues you need to deal with is how to assign a culture to display the appropriate resources. Whether you need to auto-switch locales based on browser language, or explicitly assign a locale based on user preferences there is generally some code logic involved in making these decisions. In this post I show what options are available and a small helper that simplifies setting the culture in ASP.NET applications.

Forms Auth loginUrl not working after Windows Update?

Ran into a problem with Windows Update last week that seems to have broken forms authentication and the loginUrl attribute when set. Looks like new default settings are changing default behavior, and an extra configuration key is required to get the old default behavior back.

Checking out the Helios IIS Owin Web Server Host

During last week's MVP summit Microsoft showed a new light weight, Owin host called Helios, that can run directly on the IIS core without using the ASP.NET Runtime. It's light weight and fast, and offers a glimpse into where Microsoft is heading for building a more nimble and componentized runtime that is bound to be more flexible and agile. In this post I describe how to set up Helios to play around with and some of the implications it brings.

Visual Studio 2013 'Could not evaluate Expression' Debugger Abnormality

Ran into an oddball debugger issue last week with an older project in Visual Studio 2013 where all breakpoints show 'Could not evaluate expression' instead of displaying values. This post shows the problem and a couple of ways around it.

Using HTML 5 SessionState to save rendered Page Content

SessionStorage and LocalStorage provide easy client side storage for Web applications. In this post I describe a specific scenario for caching list display data and state for a server rendered HTML application using sessionState. See how you can make a server rendered HTML application more user friendly and faster caching content on the client and redisplaying it when the user returns to a page he navigated from.

Setting up and using Bing Translate API Service for Machine Translation

Public translation APIs as a Web Service are great for doing machine translation within applications or casual translation for user input in many applications. With Google recently removing Google Translate API I've been looking at alternatives and so wanted to hook up to the still supported Bing Translate API. Unfortunately the signup process for the Translate API is terrible, although using the service is easy enough once signed up. In this post I discuss step by step how to sign up and how to use the Translate API.

Publish Individual Files to your Server in Visual Studio 2012.2

Visual Studio 2012 Update 2 introduces a little known new Web Publish feature that allows publishing individual files to the server. While not a high frequency usage case, it's handy for content files or when you just published a large project and realized you forgot to include a file in the project to publish.

Sql Connection Strings in .Config Files vs. Source Control

Connection strings in projects under source control can be problematic. Each Source Control user can potentially have different connection settings to use a database connection and these differences can't be easily reconciled via Source Control. Here are a couple of approaches that have worked for me to deal with this issue.

Visual Studio Web Publish Lockup? Check for invisible Window

If your Web Publish dialog appears to lock up Visual Studio when you click on the Publish option, most likely the Web Publish window is hidden on a second screen that is not currently visible. Here's how you can work around this annoying little bug.

Building a better .NET Application Configuration Class - revisited

Managing configuration settings is an important part of successful applications. It should be easy to ensure that you can easily access and modify configuration values within your applications. If it's not - well things don't get parameterized as much as they should. In this post I discuss a custom Application Configuration class that makes it super easy to create reusable configuration objects in your applications using a code-first approach and the ability to persist configuration information into various types of configuration stores.

Set-Cookie Headers getting stripped in ASP.NET HttpHandlers

Ran into a nasty problem with Cookies not getting sent in HttpHandler code when using Response.AppendHandler() with the Set-Cookie key. It turns out it's a very narrow edge case, but one that can bite in unexpected system level applications.

DevConnections Session Slides, Samples and Links

Finally getting around to posting links to my DevConnections session in Vegas a couple of weeks ago. It was a fun time after a long absence from speaking...

Caveats with the runAllManagedModulesForAllRequests in IIS 7/8

IIS 7 and 8 support using Managed Modules to handle access to all IIS request content which is very powerful. But sometimes you actually want to not handle non-ASP.NET content and it's not very obvious how to minimize access to non-ASP.NET requests in managed modules.

Creating STA COM compatible ASP.NET Applications

When it comes to deploying STA COM components in ASP.NET only WebForms has native support for STA component. Other technologies like MVC, ASMX Web Services and WCF run only in MTA mode. If you need to run your STA COM Components in ASP.NET here is what you need to know and a few tools that help you create STA compatible handlers.

.NET HTML Sanitation for rich HTML Input

If you need to sanitize raw HTML for display in Web applications, the job at hand is scary for .NET backends. Unfortunately it seems there aren't a lot of tools available to help in this formidable tasks and the tools that are tend to be inflexible to the point of often being unusable. In this post I show a base implementation of an HTML Sanitizer that can be customized for your own needs.

Rendering ASP.NET MVC Views to String

Creating templated text output that's not tied to the HTTP output stream is a frequent requirement in my applications. Rendering confirmation emails, password resets, validations and notifications all generate text through templates that require string or stream output that doesn't get sent to HTTP. Here are some helpers that make it easy to create string output from MVC Views...

DropDownList and SelectListItem Array Item Updates in MVC

Ran into an 'interesting' behavior today with a cached list of SelectListItem[] in drop downlist where the cached list was getting updated by MVCs model binder.

Getting a 'base' Domain from a Domain

I was surprised to see that there wasn't some way in .Net to retrieve the base domain name from a sub-domain. For example, I want www.west-wind.com, and store.west-wind.com to return me just the base url. Easy enough but there are a couple small issues to check for especially when dealing with string based domain names.

Using an alternate JSON Serializer in ASP.NET Web API

The default serializer in ASP.NET Web API (at least in Beta) is the DataContractJsonSerializer with all of its warts and inability to not serializer non-typed objects. In this post I'll talk about the issues and how to plug-in alternate JSON parsers to handle more complete JSON serialization in Web API.

Removing the XML Formatter from ASP.NET Web API Applications

When viewing ASP.NET Web API output in browsers the content is usually displayed as XML which is not my preferred choice. Even though JSON is Web APIs default format XML continues to be displayed. Here's some discussion on why this happens and how you can work around it.

Using the HTML5 <input type="file" multiple="multiple"> Tag in ASP.NET

HTML5 allows for multiple files to be uploaded from a single file input control. Here's how you can use it and capture files in ASP.NET.

HTML 5 Input Types - How useful is this really going to be?

The HTML 5 input controls enhancements seem like a nice feature - until you look a little closer and realize that that validation and styling these control enhancement use are likely going to interfere with your existing application logic and styling. Here are are some thoughts on the subject.

Using the West Wind Web Toolkit to set up AJAX and REST Services

In this post I describe how to use the West Wind Web Toolkit to create an AJAX/REST service that can serve data to a JavaScript applications with a few short steps. Then we'll look at ways to access the server side code with simple jQuery/JavaScript code and the ajaxCallMethod() helper.

Figuring out the IIS Version for a given OS in .NET Code

Need to find the IIS version available for a given OS via code? Here's a small routine that handles this.

ActiveX component can't create Object Error? Check 64 bit Status

When moving applications to 64 bit servers be sure to check that you don't call old school, 32 bit COM objects. If you do these COM object calls fail. Thankfully IIS 7 and later allows Application Pool configuration to enable 32 bit operation to work around this issue. Here's how.

Building a jQuery Plug-in to make an HTML Table scrollable

Table displays in limited space require some rendering alternatives. While paging is a common way to address fixed size displays, it's not an end-all solution. Sometimes it's necessary to display larger amounts of data in a small fixed space on an HTML page. Scrollable list are fairly easy to do with most HTML structures, but HTML tables are notoriously difficult to manage when it comes to scrolling. In this post I describe a jQuery plug-in that attempts to make any table scrollable by decomposing and reassembling the table into two distinct areas.

Built-in GZip/Deflate Compression on IIS 7.x

IIS 7.x makes content compression via GZip very easy. Here's how compression on IIS works and how you can set it up on your server in a few simple steps.

Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll

Ran into a problem on my 64 bit machine with IIS trying to load 32 bit dlls. Turns out this is a misconfiguration that occurred from some additional installation that failed to set a specific bitness valuie and pointed to 32 bit install. Here's what happened and how it got fixed.

Displaying JSON in your Browser

Ever need to display JSON in your browser and finding out that it's a pain? Here are some tips on how to display JSON data without pesky download dialogs or display errors in your favorite browser.

A jQuery Plug-in to monitor Html Element CSS Changes

I have the need to monitor movement of elements in an HTML document via JavaScript. Unfortunatey there are no events that fire if HTML elements are moved around the document either via dragging or by programmatic location changes. As a workaround I created a jQuery CSS monitoring plugin that fires event when a given CSS property changes.

Allowing Access to HttpContext in WCF REST Services

WCF REST Services do not make it easy to access all the features of the HTTP protocol, so in some situations it's just much easier to use ASP.NET compatibility to get direct access to the HttpContext object for access of all the HTTP headers and features.

WCF REST Service Activation Errors when AspNetCompatibility is enabled

Ran into a version problem with WCF REST Services when using on IIS and with ASP.NET Compatibility enabled. Turns out there's a potential version conflict in the system .config files that can cause this error to creep up - here's how to fix it.

Hosting the Razor Engine for Templating in Non-Web Applications

In this article I describe a set of classes that provide a wrapper around the Razor View Engine so you can use it easily in your own applications to provide templating functionality.

A Closable jQuery Plug-in

I've found it very useful to have a closeable plug-in that hide the content of an HTML element providing a visual close image cue. Almost every UI I build these days requires either closing pop up windows or even more commonly requires that items are removed and visually hidden which usually implies 'close' behavior. In addition to removing a bunch of HTML markup, having a plug-in is also quite useful for server controls especially if multiple behaviors (plug-ins) need to be applied.

Microsoft and jQuery

The jQuery JavaScript library has been steadily getting more popular and with recent developments from Microsoft, jQuery is also getting ever more exposure on the ASP.NET platform including now directly from Microsoft. jQuery is a light weight, open source DOM manipulation library for JavaScript that has changed how many developers think about JavaScript. You can download it and find more...

Using jQuery to POST Form Data to an ASP.NET ASMX AJAX Web Service

ASP.NET and WCF AJAX Web Services and PageMethods natively don't accept urlencoded POST requests and so standard mechanisms for sending form POST data don't work directly with these services. However, with a few adjustments and using jQuery's .serizalizeArray() function it's possible to POST form data to ASP.NET Services and easily consume the form data.

RequestValidation Changes in ASP.NET 4.0

ASP.NET 4.0 changes the way request validation works by default, pushing request validation into the ASP.NET pipeline from the Web Forms engine. This might cause some unexpected behavior if you've used the validateRequest Page level attribute to allow unsafe content to be posted but it can also cause problems in other scenarios.

What’s New in ASP.NET 4.0 Part Two: WebForms and Visual Studio Enhancements

This article describes some of the useful new features in ASP.NET WebForms 4.0 as well some useful feature enhancements in Visual Studio specific to Web Development.

What’s new in ASP.NET 4.0: Core Features

Microsoft released the .NET Runtime 4.0 and with it comes a brand spanking new version of ASP.NET – version 4.0 – which provides an incremental set of improvements to an already powerful platform. .NET 4.0 is a full release of the .NET Framework, unlike version 3.5, which was merely a set of library updates on top of the .NET Framework version 2.0. Because of this full framework revision, there...

DevConnections jQuery Session Slides and Samples posted

I've posted my slides and samples from the DevConnections VS 2010 Launch event last week in Vegas.

Rendering ASP.NET Script References into the Html Header

ASP.NET natively supports script embedding only into the body of the HTML document which is limited in many ways if you need more control over how scripts load under program control. In this post I'll show one of my components that allows embedding scripts and script references in the header of the document as well as many useful script embedding features for ASP.NET.

Making Sense of ASP.NET Paths

ASP.NET includes a plethora of functions and utilities to retrieve information about the current requests and paths in general. So much so that it's often hard to remember exactly which path property or method you are actually looking for. This update to an old and very popular post from this blog summarizes many of the paths and path related operations that are available in ASP.NET.

A free standing ASP.NET Pager Web Control

Although there's decent Pager support in ASP.NET controls the way paging works is inconsistent and not very generic. After a recent experience of creating a small pager component for MVC I decided having a generic non-data or control dependent Pager WebControl would be useful. In this post I cover a custom Pager control implementation that addresses some of the shortcomings with the stock paging functionality for me.

DevConnections Slides and Samples Posted

I've posted my slides and samples from my 3 DevConnections sessions for you to download and check out.

Capturing and Transforming ASP.NET Output with Response.Filter

Capturing ASP.NET response output can be done in a variety of ways. In this post I'll discuss how you can use a Response.Filter to capture output and transform it using a simple class that provides event hooks to make it easy to capture output.

ClientIDMode in ASP.NET 4.0

The new ClientIDMode in ASP.NET 4.0 is one of my most anticipated features to reduce the naming clutter that ASP.NET naming container naming has traditionally introduced into page. In this post I describe the ClientIDMode behavior and the various ways of how you can control ClientID generation with ASP.NET 4.0

Ambiguous References in DefaultWsdlHelpGenerator.aspx

Ran into an odd problem today where the default ASMX Web Service help page was blowing up with DataBinding errors due to ambiguous class names. Turns out that a custom control with the same name as a System component and a static method call resulted in ambigous reference errors.

Debugger Visualizers not working in ASP.NET Medium Trust

Debugger visualizers are quite useful for looking at common content while in the middle of debugging your application. However I've run into a number of problems with the debugger visualizer not popping up in ASP.NET applications due to the security environment. Turns out you need full trust in order to use debugger visualizers in ASP.NET applications.

Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth

OpenId is getting more popular and with it requests to integrate it into Web sites as a user authentication mechanism. In this post I'll discuss the OpenId integration on CodePaste.net in an ASP.NET MVC application disuccing both high level OpenId concepts, the process and the code implementation.

Making jQuery calls to WCF/ASMX with a ServiceProxy Client

This post revisits the WCF/ASMX ServiceProxy that can be used to make native jQuery calls to ASMX and WCF AJAX services. The component is self contained and provides JSON conversions including dates, as well as a simple class interface for simple one line service calls and consistent error trapping. This is an update that handles native JSON parsers. Includes examples and a detailed walk through on how it works.

Speaking at the Portland Area .NET User Group on Tuesday Sept 1st

I’ll be speaking at the PADNUG meeting next week in Portland at the Microsoft office. Rich Hubbins asked me to present on jQuery again as I did last year. A lot has changed in the last year and when I gave the last presentation jQuery was just starting to get some attention in the .NET world. By now many more people have been using jQuery for a while so  this talk likely will hit a different...

WebResource access in ASP.NET MVC

WebResources are useful when building more complex components. In MVC ASPX Views you can still access the ClientScript object to retrieve ResourceUrls, but outside of the ASPX view there's no easy access to the ResourceUrl. This post describes how grab resource urls in a couple of different ways.

Introducing CodePaste.NET

As a learning experience for taking ASP.NET MVC for a spin I recently created a new site that has now gone live: Codepaste.NET which provides a public location to post code snippet and link them from social network sites that have limited input lengths and make code discussions otherwise difficult. The site's a work in process, but I hope it's useful to some of you for sharing and discussing small blocks of code online.

Url.Action() and RouteValue Encoding

When creating custom URLs with the UrlHelper.Action() method is a great way to create links to other URLs in the current Web application. However, you need to be careful of certain encoding issues as certain characters are not correctly encoded to work properly as parameters.

How do ASP.NET Application_ Events Work

Most of us have used ASP.NET global.asax Application_ EventName handlers, but do you know how it is that these events are actually fired automatically by ASP.NET even when you add additional events by name? In this post my curiosity got away from me and I took a look under the covers to see what ASP.NET is doing to hook up these method to HttpModule events.

Creating a quick and dirty jQuery contentEditable Plugin

Inline editing content is a feature that's novel and highly useful at the same time. I've been using it in a number of admin interfaces to provide very easy and quick text updates to existing content. There are a number of ways to accomplish this but in this post I'll discuss a contentEditable jQuery plugin that makes any content inline editable using the DOM's contentEditable attribute that maintains text formatting in the editable text.

Don’t use Response.End() with OutputCache

Got bitten by a silly problem that nevertheless has happened to me on several occasions: I'm trying to use OutputCaching in an HttpModule and found that the output simply NEVER cached. After some lengthy debugging I realized I missed an obvious problem that stared me straight in the face: A Response.End() after output generation that causes the pipeline to bypass caching.

Adding Default Assemblies, Namespaces and Control Prefixes in Web.Config

One often overlooked feature of the ASP.NET runtime is the ability to specify default namespaces and control prefixes in web.config which can make it much easier to reference components in your pages. As more and more developers move away from using the designer and live exclusively in markup getting your custom controls to show without @Register tags is especially useful. Here's how.

IIS 7 Error Pages taking over 500 Errors

I've been running into a problem with IIS returning error pages when my application is actually returning 500 errors along with custom content. IOW, IIS is taking over error display completely even if I send my own content for errors. This has some profound effects on error handling and on some custom handler implementations that relying on returning error information to the client. Thankfully there's a new ASP.NET 3.5 property that helps with this problem, although it's a rather obscure fix for this issue.

Creating Visual Studio Templates from your Web Projects

Visual Studio has the nice capability to create project templates from existing projects and with a little bit of work it's real easy to create a project environment that's ready to roll without having to dig for related components first. This applies to Web projects more than anything for me as I have a fair bit of generic utility code that is project specific and needs to be added to just about all projects. Templates make this real quick and easy. Here's how.

Web Application Project generated CodeBehind .designer file not being updated

I've been running into problems with WAP page CodeBehind files (.designer.cs) files not being updated from time to time. Here's how this can happen and a few ways to fix the problem and get on with life.

A Localization Handler to serve ASP.NET Resources to JavaScript

Here's an implementation of an HTTP handler that can serve ASP.NET Server resources to JavaScript clients easily. The handler can provide both local and global, normalized server resources to client JavaScript pages so that you can localize resources in one place on the server. Use standard Resx resources or our custom database resource provider.

Updated Westwind.Globalization Data Driven Resource Provider for ASP.NET

I've updated the ASP.NET Data Driven Resource Provider code base and examples. There are a number of small improvements based on user feedback as well as a few new features like a new JavaScript Resource Handler that can provide server resources to JavaScript code easily.

Getting an ASP.NET Application Relative Path from a Logical Path

On a few occasions I've found it necesary to retrieve an application relative path. ASP.NET provides tons of path related functions but there is nothing generic that provides purely application relative paths. Here are ae couple of functions that provide that for local pages and for any page based on a logical path.

Opening a WAP IIS Project when IIS Virtual doesn’t exist

Web Application have a nice feature to create a virtual if it doesn't exist and you're using IIS for your project. Unfortunately if you don't want to create a virtual the operation unceremoniously doesn't load your WAP project. Here's how to get around this and a suggestion on how this feature could be improved.

Showing Syntax Colored Source Code in ASP.NET Content

Code Syntax Highlighting in HTML pages and the ability to display source code for specific pages in samples is something I do a lot of. Here is what I use for code highlighting in text snippets and for displaying source code in samples easily.

Using Enums in List Controls

Using enums for display value in applications can be nice and easy with a little bit of help. While enums generally shouldn't be treated as data, in some situations it might just be more convenient to use enum definitions rather than database look up tables for data that is defined in the object/domain model. Here are a few ways you can easily use these enum values.

Error Creating Control Errors in the ASP.NET Designer

I've been suffering from ASP.NET designer errors that force a Visual Studio restart. I don't use the designer very much - just for a few special cases like using Extender controls - but when I do the designer is incredibly frustrating and here is another example just why.

Removing the .SVC Extension from WCF REST URLs

One of the most frequent questions that come up when talking about WCF REST urls is how to remove the .SVC extension from the endpoint Url for a REST service. While it's not automatic, there are a couple of fairly simple solutions to this problem: Using the IIS 7 Rewrite Module or a small custom module.

jQuery and ASP.NET Article Part 2 Posted

I've posted Part 2 of my jQuery with ASP.NET article series. Part 2 deals almost entirely with making AJAX callbacks to ASP.NET using several different mechanisms to retrieve data from the server for client side consumption. Covered are external content retrieval, same page callbacks, WCF/ASMX and a pluggable custom callback implementation that can be used with any application. Also covered is client side templating for managing HTML in one place.

WCF REST Services and AJAX Callbacks

I've been getting a lot of questions in response to my WCF REST session in regards of whether I'd recommend switching to WCF from ASMX services for AJAX functionality recently. WCF provides a host of new REST features, but when it comes to AJAX functionality and especially ASP.NET AJAX compatible functionality there's really nothing compelling there to require changes. In this post I look at what WCF provides for AJAX and some of the things you might watch out for.

ASP.NET Connection Session Slides and Samples Posted

I've published my session slides and samples from the Fall 2008 ASP.NET Connections conference. The sessions include: jQuery and ASP.NET, WCF REST and JSON with ASP.NET and Dealing with Long Running Requests in ASP.NET.

From ASP Stock Projects to Web Application Projects in VS 2008

Had to do a conversion of a stock ASP.NET project to Web Application projects after not having done so in quite some time and it looks that this process still is not any easier than it was when WAP was a separately installed project type. Here are steps to move a project from stock to WAP with a few hopefully helpful hints.

HTML Mangling with Literal Controls in the <head> tag

Ran into an odd problem with Literal controls in the head tag of the document causing HTML to get corrupted today. It appears that literal controls - and only literal controls - are causing some odd designer manglage that can result in broken HTML.

Introduction to jQuery Article posted

I've posted Part 1 in a two part series on jQuery today. Part 1 covers the client side features of jQuery from the basics all the way through creating simple plugins and extending jQuery. This is a long article that discusses a host of the really useful features that jQuery brings to the table for client side Javascript development. Part 2 will then follow up with server side ASP.NET integration.

Browser Rendering Differences and Browser Resets

As ASP.NET develoers it can be really easy to not pay attention to good CSS style layout practices. But CSS is vitally important especially when dealing with different browsers and consistent formatting. Using browser resets in particular is a big help in taking some of the pain out of cross browser rendering differences.

ASP.NET Designer Control Problem in VS 2008 SP1

I've been running into problems with VS 2008 SP1 where controls appear to be failing frequently with property assignment errors that seem completely unwarranted. Controls work fine on a page, and next thing I know they fail for no apparent reason.

Client Script Resources in ASP.NET Controls revisited

Embedding script resources as part of ASP.NET Control development is tricky business and requires a bunch of options to ensure that script code loads correctly and maybe more importantly allows the page developer to decide whether the resources should be used at all. Here are a few thoughts and some work in progress on how I deal with script resources in my controls.

Retrieving Web Resources and Content Types in Code

One of my components requires to serve specific Web Resources directly and optionally compress them optionally. While serving resources is straight forward, also grabbing the content type to know what type of resource you're dealing with is a little more work. Here's how.

jQuery Form Serialization without ASP.NET ViewState

When building AJAX applications that send client form content to the server, ViewState and EventValidation fields can get in the way. Using jQuery you can make short work skipping over these fields and send only the raw POST data to the server.

Watch out for Date Kind in JSON Deserialization

If you're working with dates in JSON serialization make sure you carefully normally dates returned from JSON deserialization. Reason is that especially the Microsoft Serializers return dates as Utc dates which can produce some unexpected and often missed results.

FireFox 3 and Static File Caching Problems

FireFox 3.0 apparently is much more aggressive in caching content than previous versions of FireFox. While this is good for performance in many situations I've noticed that this is seriously becoming a problem in some of my applications where support files like scripts and CSS files get updated in applications and FireFox doesn't recognize those changes. The problem appears to be that FireFox is...

Unable to debug Web Site with Top Level Location

Ran into another fun little problem a few days ago. Working on my root Web site which is rather large and contains a huge number of sub-webs. The root site is very light in terms of ASP.NET functionality used - primarily stuff like cookie tracking and logging tasks, serving banners etc and a few utility applications. Most of the heavy lifting on the site and 'real' applications are managed in...

Lost (and found) Visual Studio Templates in Web Project

So I just lost all of my project templates in Web projects. I've been working on a small utility page on my site that generates help documentation on the fly. I've been working happily along on this site when all of a sudden when I needed to add a config file to control debugging and authentication on this page/app. could not find a part of the path 'C:\programs\vs2008\ Common...

ASP.NET gets no Respect

As an ASP.NET developer I'm pretty much sold on ASP.NET as a platform. I've used ASP.NET since the beginning of the early .NET betas and while I originally had a tough time getting started with it, I eventually came to really enjoy the framework. But once I understood the platform and the flexibility it offers, it's now really hard to think of any other Web development platform that I'd rather be...

Server Errors when updating live Web Applications online

In the last few weeks I've been noticing some problems with site updates I've made to my live server. I have an application running locally and it's running fine without problems. The app is running as a Web Application Project (WAP) and so when I update the application most of the time I only update the BIN folder and possibly one or two of the ASPX markup pages. So I upload all files out of the...

JSON Serializers in .NET - not there yet

.NET Framework 3.5 provides a couple of choices for JSON Serialization and Deserialization. Find out how you can use them and also some of the problems that both of these tools impose.

jQuery with ASP.NET Presentation at Portland .NET User Group on Tuesday

I'll be doing my annual presentation at the Portland Area .NET User Group (PADNUG). The topic this time around is Using jQuery with ASP.NET which is a fun presentation that covers JavaScript and specifically jQuery use with ASP.NET without using ASP.NET Ajax. Here's the presentation abstract: Using jQuery with ASP.NET jQuery is a compact and powerful JavaScript library that is quickly becoming...

West Wind Ajax Toolkit updated

I've finally had some time to update the West Wind Ajax Toolkit to version 1.90. A number of these changes I've written about and have updated previously, but this update finalizes a number of these updates into a full release. There are a number of enhancements to the existing functionality as well as a few new helper components that I'm finding very useful these days. As always you can grab the...

Static Singletons for ASP.NET Controls

When building generic ASP.NET Server controls that also provide a sort of API service to other custom controls or page level code, it's often necessary to ensure that only a single instance of a control exists, and that only that single instance of this control or component can be accessed in the context of an ASP.NET request. Using HttpContext and it's Item collection makes it easy to create reusable, cacheable instances and ensure you're only running a Singleton instance of it.

Updated jQuery and WCF 3.5 JSON Samples posted

I've updated my slides and samples for last spring's Devconnection's sessions to reflect some of the recent updates in jQuery and jQuery.ui, which now have been updated to release versions. In addition there have been a few bug fixes and better configuration documentation for the samples.

Ending a Response without Response.End() Exceptions?

There's not really a clean way to end the current Response output and then keep on processing an ASP.NET request. Here's a scenario and a few observations on Response closing behaviors.

Non ASPX Extensions and Authentication in the IIS 7 Integrated Pipeline

Ran into an issue where IIS 7's integrated pipeline exhibits different behavior authenticating non ASPX extensions. Looks like IIS 7 only authenticates mainline files resulting in Context.User==null or Context.User.Identity.IsAuthenticated==false. For example hitting CustomHit.axd doesn't provide user credentials where an ASPX url does.

jQuery puts the fun back into Client Scripting

jQuery is a small, yet very powerful and extremely addictive JavaScript library, that's rescued me from my JavaScript phobia I've had for many years. Although I've dabbled for years off and on with JavaScript I've not really had any joy with it until I started using jQuery. Here is my take on why this library is such a kick ass tool to have in your Web development toolkit.

jQuery.ui Sortable

Sortable lists are a common thing to work on and jQuery.ui's Sortable plug in makes it super easy to create very nice looking sortable lists that work consistently even in complex layouts.

jQuery AJAX calls to a WCF REST Service

Here's an overview of how to call WCF REST services with jQuery. The basic process is very easy, but if you want to handle the formats that Microsoft sends down reliably, you have to make some format choices and deal with JSON encoding and decoding that is not native to jQuery.

WCF REST Configuration for ASP.NET AJAX and plain REST Services

.NET 3.5 includes WCF REST service functionality that allows for cleaner HTTP access to services. For AJAX applications this means that WCF can now be used both for MS AJAX clients as well as non-MS AJAX clients like jQuery or Prototype. This post focuses on setting up and configuring WCF for REST operation with a focus on AJAX scenarios looking at some of the different configuration options available.

WCF REST Services and Could no load file or assembly... Error?

I'm working with a few different WCF REST services for some demo code and I've been getting an inconsistent error, every few hours. I've been getting the old "Could not load file or assembly... or one of its dependencies. The system cannot find the file specified" errors when accessing the WCF .SVC file in an ASP.NET hosted WCF service: The odd thing about the error is that it only occurs with...

Client Side Templating with jQuery

When building AJAX applications there's often the requirement to choose between client and server side rendering. Server side ASP.NET controls provide rich templating, but updating those controls on the client can be difficult. Or is it? Here's one approach using jQuery and HTML templates in markup script to dynamically create complex layout on the client without writing reams of script code.

Rendering individual controls for AJAX Callbacks

It's quite handy to render HTML as part of AJAX callbacks and spit it back to the client. It's quite easy in fact to take advantage of ASP.NET Web Form rendering to render individual controls or compound user controls and pass them back to provide partial rendering even if you're using tools like jQuery, Prototype etc. rather than using ASP.NET AJAX.

Where's my .NET 3.5 (on IIS), Dude?

I just delivered a small 3.5 application to a  customer in compiled form and told him to install the application on IIS. The company is one I've dealt with on a few occasions and they are .NET aware shop where I deal with developers and a .NET familiar IT department. But it wasn't long after I sent my email that I got a call back from the customer who - slightly embarrassed - mentioned that they couldn't find the 3.5 Runtime option in the ASP.NET configuration panel.

Grayed out ASP.NET Toolbox Controls? Check your Mouse!

Have you run into a problem with the ASP.NET where you can't access toolbox items for add-on controls? You're not the only one. Apparently there's a bug that causes some hardware configurations involving Microsoft Laser mice to cause problems with the idle state that the designer uses to refresh controls and certain designer aspects.

Debugging Http or Web Services Calls from ASP.NET with Fiddler

If you've tried to trace Http requests to Web Services or WebRequest calls in an ASP.NET application you've probably found although ASP.NET requests show up in tools like Fiddler or Charles, but the Web Service or WebRequest/WebClient calls do not. You can make this work however by modifying the proxy settings in web.config explicitly.

Firefox 3.0 XmlHttpRequest Default Content-Type change

I ran into a small problem with some of my AJAX code that's checking content-type on inbound requests from the client - it looks like FireFox 3.0 is now including the charset on the content type from the client on POST operations which if not explicitly checked for can break existing code expecting only to see a content type. Small issue, but easy to miss especially in framework code like mine that frankly should have been prepared for this...

Updated Data Driven ASP.NET Resource Provider Posted

I've update the source and samples for the wwDbResourceProvider component which provides an ASP.NET Resource Provider that is driven from resources stored in a SQL Server database. The tool also includes a real time ASP.NET resource editing front end and the abillity to import and export resources. This update fixes a few small bugs and enhances the ASP.NET resource editing front end with a few UI and AJAX tweaks.

Watch out for Collection property Setters in ASP.NET Controls

If you've ever run into the ASP.NET Control Design time error "Cannot create Control" you may have run into a small but easy to miss details about collection properties in ASP.NET controls: The controls can't have a setter if they are serialized from the designer or an error will occur in the designer even while code runs just fine at runtime.

Embedding ASP.NET Server Variables in Client JavaScript, Part 2

This post discusses some updates to the wwScriptVariables class I talked about last week. This class provides an easy way to access server variables in client script, automatically expose ClientIDs as simply ID values and provides a mechanism for client code to send updated values back to the server to consume easily.

Embedding ASP.NET Server Variables in Client JavaScript

Getting Server Variables embedded into a page and using them from JavaScript code can be a pain. Following Jon Galloway's post a few days ago I thought that maybe a more generic solution that doesn't rely on ASP.NET AJAX and is more generic might be useful to make the task easier and apply much broader scope. The result is an easy to use, generic class that generates a JavaScript object from key value pairs created on the server with static values or dynamic control or object properties.

jQuery Intellisense in Visual Studio

Getting jQuery to work with Intellisense in Visual Studio is now possible after Microsoft updated script parsing code in a recent hotfix. Although there are improvements in basic parsing and some Intellisense is supported, by making some very minor comment changes to jQuery.js can improve Intellisense support drastically.

Visual Studio Hotfix for Slow Web Forms Editing and Input Focus Issues

Microsoft has just released a hotfix for a number of issues that have been plaguing me for some time in Visual Studio 2008. The issues involved have to do with the visual designer and the HTML code editor and a number of different input focus and slow input situations. You can get the hotfix from here:...

Linq to SQL DataContext Lifetime Management

The DataContext is the central object that holds LINQ to SQL together. This post talks about a few different approaches you can use to hang on to your DataContext in the course of a request, to pass between layers or to manage on a per thread/request level.

Issue: Migrating Web Application Projects between VS 2005 and VS 2008

If you move Web Application Projects between Visual Studio 2008 and Visual Studio 2005 and a machine that doesn't have Visual Studio 2005 installed you will find that the project doesn't load due to a build target difference.

Forms Authentication and path= in the <forms> Tag

Ah the beauty of a self made blunder - I managed to bungle up a tag's path in web.config which caused some very unpredictable behavior that essentiall failed all forms authentication requests.

SmtpClient in Medium Trust

SmptClient is supposed to work in Medium trust and it in fact does work, but only if you use Port 25. I ran into an unexpected failure while connecting to my ISP who requires an alternate port for SMTP access outside of their network.

Griping about System.Net.Email.SmptClient/MailMessage

For many years I've been using a home built SMTP client I built using low level Sockets. Single class, set a few properties and it goes off and sends emails. With about 5 lines of code I can be off sending an email from just about any app Web or otherwise. I created the custom class originally to...

Doing away with an Assembly Dependency

I'm looking at some oldish code that sits inside of a web control library. This is my main web control library were I keep all of my custom controls that I typically use. It includes all the AJAX controls, a custom databinder, some generic status display controls, a number of stock control...

wwHoverPanel/West Wind Ajax Toolkit Updated

I've finally had a bit of time over the holidays to roll in a few updates into my wwHoverPanel library. In the process I decided that wwHoverPanel is not really a fitting name for the library anymore since it does quite a bit more than that by now, with the hover panel operation only being a part...

Visual Studio and <location> parsing in web.config

So here's a funky Visual Studio behavior: On my root Web site (which is mostly static) I have my web.config set up to handle the root site configuration in a separate <location> element in order not to force the settings of the root site down into the many, many virtual...

Weird DataGrid Paging Error with Last Page Selection

This is one posts of an oddball problem I've run into where I feel like I 'shoulda known' but just didn't for - way too long <g>. I have a form in my Web Store with a DataGrid on it. Yeah the form is pretty old and dates back to 1.1 but I hadn't changed over because the page is inherited and...

DataContractJsonSerializer in .NET 3.5

.NET 3.5 includes a new DataContractJsonSerializer that makes it real easy for serializing and deserializing .NET objects to and from JSON. This post shows code for simple serialization and deserialization as well as discussion of some of the features and limitations.

ClientScriptProxy and JavaScript Linking In Headers

.NET 3.5 includes a new DataContractJsonSerializer that makes it real easy for serializing and deserializing .NET objects to and from JSON. This post shows code for simple serialization and deserialization as well as discussion of some of the features and limitations.

JSON and Date Embedding

I'm a bit mystified by various JSON implementations out there that don't seem to be dealing with dates correctly. I've been using Douglas Crockford's JSON implementation from JSON.org and originally I had to fix up the date processing so that it would work on both ends for serializing and...

Charset Encoding in ASP.NET Response

I was reviewing some control and handler code in my wwHoverPanel control's AJAX callback handler code. There are a number of routines that generate JavaScript output from JSON to returning resources and I noticed that the content type headers would often vary slightly. When returning a content type...

Updated jQuery Calendar to jQuery DatePicker

A couple of months ago I posted an ASP.NET wrapper around Marc Garbanski's Calendar control. Just so was my luck that a couple of weeks after I created the control Marc rev'd the jQuery control, renamed it and basically overhauled the control for it's inclusion as part of the jQuery UI suite....

Updated ASP.NET wwCaptcha Control on the WebLog

Sat down yesterday to create a quick imageless Captcha control that is self contained in a single page using simple Math expressions instead of images to handle page validation to avoid the multiple hit and Cache hit transferring information between the page and an HTTP module.

LINQ To SQL and the Web.Config ConnectionString Value

I just got had by an odd behavior in the LINQ to SQL model designer when working with a LINQ to SQL Model in a separate class library project. I use LINQ to SQL in a business layer which always lives in a separate assembly and so the model does not live in the same project as the Web (or other)...

What's Ailing ASP.NET Web Forms

The recent announcement that ASP.NET will soon get an alternate engine in the ASP.NET Model View Controller framework (MVC - see last month’s editorial) has brought out some renewed discussion of the merits and shortcomings of Web Forms and the potential need for an alternate mechanism of building...

Getting Images to render properly in the ASP.NET Designer

I'm embarrassed to say that I didn't quite know how to get controls to render image urls properly in the designer. The situation is as follows: You create a custom server control and you have an image property and you allow the use of the ~/images/someimage.gif syntax to specify the image path. I...

Debugging a FoxPro COM Object under ASP.NET

Some time ago I posted some code that you could use with ASP.NET to debug COM objects somewhat interactively in Visual FoxPro. The old approach used an old trick to instantiate VisualFoxPro.Application from within IIS and then actually launching code to instantiate an object created inside of VFP...

Implementing a jQuery-Calendar ASP.NET Control

I've posted a wrapper ASP.NET around the jQuery-calendar control from Marc Garbanski. This small client side calendar control is compact, looks nice and is very easy to use and I've added an ASP.NET wrapper around it so it can more easily be more easily used with ASP.NET applications by dragging and dropping onto a form and supporting postbacks of the SelectedDate.

A simple Business Object wrapper for LINQ to SQL

I've been talking about how I'm using a small business object wrapper around LINQ to SQL to provide better abstraction of the LINQ to SQL functionality and I suppose the time's come to be bit more specific. This is going to be a long post with a fair bit of code and a brief discussion of the whys and hows...

ASP.NET and Styles & CSS Embedding

One thing that really bugs me about ASP.NET is the way it deals with header management especially when working with Themes. One of the big problems I see is that ASP.NET embeds the Themes style sheet at the bottom of the header list. If you happen to be using Master Pages which can have a header...

Forms Authentication and Persistant Login Problems

I'm mucking around with an authentication form that requires some extra authentication data for the user, so rather than using the stock Login control and it's authenticate method I'm using a custom ticket and manually redirecting the data. I'm not sure how this option to stick custom user data...

jQuery and jQuery UI and maintaining a custom Client Library

I've been spending some time over the last couple of days working with jQuery and a few helper components. jQuery a week ago or so released version 1.2 and a few days later a new jQuery UI library which looks to be pretty cool for a number of reasons. If you haven't looked at jQuery before I...

LINQ to SQL Serialization bites me again

I'm mucking around with a bit of code today that's using AJAX and returning some data from my business layer that's using LINQ to SQL Entities. I mentioned some time that one issue that I ran into and continue to bump my head against is that LINQ to SQL has big issues serializing its entities. The...

ResolveUrl() without Page

If you're writing generic non-Page code in handlers, modules or other system components for ASP.NET you might find that at times you need to use ResolveUrl(), only to find that this functionality is not available outside of the Control class. Here's a generic routine, and another variation that can return a fully qualified absolute path using the familiar ~ syntax outside of the Page framework.

Missing PageMethods on an MS AJAX Page?

You ever have one of those days when just nothing wants to go right? A couple of days ago I was working on my session code for ASP.NET Connections. One of my sessions is on Dealing with Long Running Requests and one of the examples uses AJAX to offload the processing to messaging engine and...

wwHoverPanel AJAX Control Updated

I've updated the wwHoverPanel library yesterday with a number of small bug fixes and a handful of new features and enhancements. Most of these are cosmetic. wwHoverPanel is a small AJAX library that I use in my internal tools and products and it provides a few core features: Simple JSON remote...

FormVarsToObject - a quick way to collect form input values

Here are a couple of small routines that let you quickly collect ASP.NET form variables into an object or a data row with a single line of code. This routine comes in handy in many situations where full databinding may not be involved or more commonly in AJAX scenarios where no form databinding can be applied on Page level callbacks.

Dynamic Expressions in Linq to Sql

Using LINQ there are two issues that I've been struggling with and both have to do with dynamic query results: Hitting the wall with SQL that can't be expressed via LINQ and using dynamic expressions inside of LINQ queries from within framework level code. As it turns out there are ways that this can be addressed with lower level LINQ methods that provide the abillty to be a bit more flexible in controlling what SQL gets executed and creating dynamic expressions for results.

Creating a scrollable and grouped Repeater Layout

A couple of people asked me today about a layout I put together for an application. The layout is bascially a scrollable and grouped repeater that looks a little like a ListView control in WinForms. This sort of layout can be great for longer lists when paging is not really the right choice - a common scenario in AJAX applications actually. Here's a quick walk through on how this layout is put together.

Strong Name Validation failed when Debugging ASP.NET on IIS7

Ugh, since I installed a new machine I ran into this error message above earlier. That's a pretty omnious sounding error message which seems to hint at a mis-configuration during installation. The error occurs as soon as you try to debug a Web application against IIS 7... As it turns out the...

GridView and Paging Alignment

The GridView's Pager row is a pain to get properly right aligned in a cross browser fashion. While the alignment settings that the control provides work in IE, they fail to properly right align in Firefox and a bit of work is required to get it to work right.

LINQ to SQL and Disconnected Entities Follow-up

Several people have been flogging me for my LINQ and disconnected Entity post, so I thought I should follow up on the issues I've been having. First let me restate Entity issue I raised a couple of days ago, but let me present it in a simpler context with the Northwind database, so you can try...

IIS/ASP.NET Settings and Virtual Directory Inheritance

Root directory web.config settings can easily interfere with child virtual application settings causing all sorts of problems. Here's why this is a problem and how to get around it.

Shutting up Invalid ViewState from SPAM bots

Somehow, sometime ago a spambot got into my Web Store and picked up a couple of pages and decided to just POST random (and randy <s>) SPAM to this URL to the tune of a few hundred POSTs a day by now. The funny thing about this is that the URL is just a product page that accepts only a...

Web Application Project Conversion on Orcas

I'm going once again through a conversion from Stock Projects to a WAP project conversion this time for my Web Store. I've done the conversion once before but returned back to stock projects because of a Visual Web Developer requirement. Recently though development on the store has been a lot...

Resource Unloading in a custom ASP.NET Localization Resource Provider

In ASP.NET 2.0 ResourceProviders allow extension of the native resource mechanism with your own resource backing store by implementing a custom ResourceProvider. It's fairly easy to create a new provider but figuring out how to unload resources with a dynamic resource store like a database is not quite straightforward. Here's how...

Loading an ASP.NET Page Class dynamically in an HttpHandler

I ran into an interesting post on the ASP.NET forums today where someone is trying to dynamically invoke a page class inside of an HttpHandler. Basically the idea is that you have a class for the page that exist and you're dynamically invoking the class rather than letting the ASP.NET BuildManager...

Stupid Pet Trick # 522

Thought I'd share a really silly developer story here. A while back I built a scheduler application for ASP.NET which checks a POP3 mail box and looks for certain content. The app just pulls all messages and deletes them as it finds them (optionally) and forwards them to another email address with...

Creating a data driven ASP.NET Resource Provider and Editor Article posted

I finally managed to write up my data driven resource provider as an article. It ended up being quite a task getting it all to fit into an article and I actually ended up with TWO freaking articles - one an introduction and one for the resource provider and editor implementation. <s> Yeah,...

Generate Local Resources forces Culture="Auto" into Page

Here's a real annoyance in Visual Studio's Generate Local Resources feature: When you generate local resources within the IDE ASP.NET will automatically add Culture="Auto" and UICulture="Auto" to the page header. While this may seem Ok at first  this is really, really lame if you are managing...

Embedding JavaScript Strings from an ASP.NET Page

I'm looking at a piece of code that's a custom control that embeds a bit of JavaScript into a page. Part of this JavaScript is generating some static string text directly into the page. I've been running this code for a while now as part of an application I'm working on with a customer. But a...

IIS Application Pool Crashes due to Temp File Permissions

My Web Server has been throwing a bunch of nasty errors recently and I've been trying to figure out what the heck is going on. The problem is that apparently App Pools have been crashing hard fairly frequently. In most cases this isn't a big deal as IIS will immediately spin up another app pool,...

JSONP for cross-site Callbacks

Here's the JSONP code that uses the code I mentioned in my last post. JSONP is an unofficial protocol that allows making cross domain calls by generating script tags in the current document and expecting a result back to calls a specified callback handler. The client JavaScript code to make a JSONP...

wwHoverPanel ASP.NET Ajax Control Update

I've just uploaded a new version of the wwHoverPanel control. wwHoverPanel is a small AJAX library that provides some useful and common functionality in an easy to use and lightweight package. The library consists of a couple of controls that provide quick client side...

HttpWebRequest and GZip Http Responses

I've talked a bit about GZip compression (here and here and here) on the server recently. It's pretty straight forward to use GZip compression either by letting IIS do it for you automatically or by using some simple ASP.NET code to compress content. As a quick review to create GZip content on...

Images as Style Attributes

Here's a little tip that I started using more frequently recently that involves images. When embedding images into pages you're often inclined to use an IMG tag or an ASP.NET image control. In some situations though - especially if the same image repeats on the page - it can be much more efficient...

ConfigSection Security

I am cleaning up my localization provider code for my presentation tomorrow at PADNUG  (uh, today I guess <g>) and while I'm at it checking for proper operation in medium trust. This is the sort of thing I should be doing right from the start - start with Medium trust and then fix...

Finding Child Item Controls in ASP.NET

I was mucking around with some old control code today where I have a control that has an array of child items. While making some modifications I realized that I really wanted to make some of these controls available as child controls. But alas it turns that ASP.NET is not readily firing any 'add'...

Global Resources Localization Suggestion for ASP.NET

ASP.NET provides the ability to use strongly typed resources for Global resources that are contained in App_GlobalResources. This is a nice feature, but it has a pretty major flaw as it's implemented right now. The way this works is that you have your Resx file in App_GlobalResources and...

Hiding ASP.NET Controls from the Toolbox

I've often built custom ASP.NET controls that contain other custom child controls. For example, I have a DataBinder control that contains individual DataBindingItems which are based on Control. The problem is that by default these child controls show up on a control list. Here's what the...

IIS 7 and JavaScript Compression not working consistently

IIS 7 has improved and simplified support for GZip encoding enabled out of the box and for the most part it seems to be working well on my Vista install. I see my CSS and other text content properly GZip encoded. IIS 7 also allows you to encode dynamic content easily which is nice because that was...

Speaking at PADNUG on Wednesday: Data Driven Localization

I'll be speaking at the Portland Area .NET User Group next Wednesday. The topic is: A Data Driven Approach to Localization with ASP.NET This session provides an introduction to localization with ASP.NET as well as demonstrating how to extend ASP.NET with a custom data driven ResourceProvider. The...

STA Threading Issues in ASP.NET

Recently I built an HttpHandler to replace my ISAPI interface for Web Connection, which is an application interface that provides Web connectivity to Visual FoxPro. The ISAPI extension has been working fine for many years, however with the advent of IIS 7 I figured it's time to create a more...

Properties getting mixed up in VS 2005 ASP.NET Visual Designer

Here's an interesting problem in the ASP.NET designer in VS 2005: I have a custom control that has two properties with similar names. Somehow Visual Studio's designer appears to be getting the properties mixed up when trying to display the properties in the property sheet. Here are the property...

GridView and CommandArguments

I don't know about you, but I cringe every time I need to create a GridView based layout that needs to create a few custom link handlers off that grid. The typical scenario might be a list where you can toggle certain options or where you can fire an operation that otherwise updates the data that's...

IE Lockup with createElement and appendChild

I've been working on some client side AJAX code in a photoalbum application and I ran into a horrible situation today with IE. This innocuous code which is part of my library code (which in this case pops up an opaque overlay ontop of the page generically to render another window with an image...

__doPostBack and the Back Button

One of my Web Connection customers (but this also applies to ASP.NET) recently posted a question regarding  a page that wasn't working correctly when using the Back button. The behavior would be something like this: Go to the page Click a link that causes a __doPostBack() to occur Click the...

Downloading a File with a Save As Dialog in ASP.NET

This seems to be a common question that I hear frequently: How do I download a file from a Web site, but instead of displaying it in the browser see it as a file that can be saved (ie. see the Save As dialog)? Normally when you link a file that file will always display inside of the browser because...

Watch out with precompiled ASP.NET 2.0 Applications if you have Orcas installed

Here's a stumper. Today I made a very minor change to my Web Store application. It's basically and administrative tweak to capture spam IP addresses and store them for later optional blocking. The change made didn't touch anything in the rest of the application. The Web Store is my last app that's...

Gravatar Implementation

I took a little bit of time today to make a few minor changes to the blog here and added some enhancements to the comments section here. One of the additions is support for Gravatars which is a very simple REST based mechanism that lets you show an avatar image. Gravatar is implemented by quite a...

IE DOM's dragstart Event interferes with 'manual' Mouse Movements

I'm working on some JavaScript code for my library that does drag and drop. It's working pretty well and I'd been testing most of my code against dragging around Div tags with drag handles and content which works great. However, depending on how even bubbling is set up in certain browsers the...

Forcing an ASP.NET Application to 'stay alive'

This post in the 'stupid pet tricks' category I suppose - it's not one of the things that you need to do every day, but if you need to run an application that requires that your ASP.NET application stays up and running without the discontinuity of AppDomain or worker process shutdowns this can be...

Blocking IIS IP Addresses with ASP.NET

Over the last few months I've had increasing SPAM traffic coming to my site, usually from a few select IP address groups. Most of this site spamming crap that I actually catch tries to simply POST to every possible URL on the site apparently that contains a FORM tag, spewing forth a plethora of...

Overthinking AutoResetEvent in an HttpHandler

I'm an idiot! I spend almost the entire screwing around with some multi-threading code that was locking up on occasion. As everyone knows debugging multi-threaded code - running inside of ASP.NET no less - is no trivial matter to work with and debug. So I'm rebuilding the Web Connection ISAPI...

Dynamically hooking up HttpModules

Ran into an interesting question on the ASP.NET newsgroup today regarding a problem I've run into a few times myself. The issue revolves around virtual directory folder inheritance and web.config settings getting inherited from a root Web site. Anyway - one issue that has come up a few times is...

A dynamic class loading HttpHandlerFactory

Here are a couple of examples of how you can route custom script map extensions to your custom HttpHandlers.

Nested Item Templates for custom script extensions in Visual Studio

I'm working on an application that's using custom HTTP handlers to handle inbound Web requests where each script request is pointing at an HTTP handler. In this case the handlers need to be individual files so I have a script map configured in IIS with a special extension and then mapped to my...

Using Project Template Export to create a generic WAP Template

I have a customer coming out tomorrow for a week long gig and as I was preparing for tomorrow's session I needed to set up new project. Starting up a new project and getting all the pieces into place for a Web application involves a fair amount of setup for me usually as I typically startup with a...

System.Argument Exceptions in W3wp.exe and the VS Just-in Time Debugger

I've been noticing that on my server quite frequently I get managed exceptions bubbling up to the Dr. Watson and/or the Visual Studio Just In Time Debugging dialog on the desktop. Now this being a server machine I'm not happy about this happening of course because it clutters the desktop the next...

The Type Initializer for System.Drawing.ToolboxBitmapAttribute threw an exception

Here's a fun exception that popped up in my admin error mail box today:/wwStore/item.aspx?sku=wconnectThe type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception. on 3/11/2007 10:34:49 pm--- Stack Trace --- at System.Reflection.CustomAttribute._CreateCaObject(Void*...

MetaWebLog API and Blog Writers

Got a little time last night to add MetaWebLogApi to my Blog in hopes of being able to start using slightly more favorable HTML in my posts. I've been using Word for all of my blogging over the years and while I've tried various tools for publishing posts I've always come back to the convenience of...

Medium Trust - WebPermissions and SmtpPermissions

I'm putting the final touches on generic application that will be redistributed and one issue that I'm fretting over is dealing with some medium trust limitations in relation to Web access.

ASP.NET Projects to WAP conversion

I've had several people contact me recently regarding issues in upgrading their projects to Web Application Project from stock ASP.NET 2.0 projects. While the process is fairly straight forward, there are a few gotchas worth mentioned here.

ASP.NET Caching under Memory Pressure

On my server most of my apps are failing to store content in the ASP.NET Cache, most likely because the memory usage is pretty high and memory available is low.

Evaluating JavaScript code from C#

.NET includes support for JavaScript as a .NET language, but it's not talked about a lot. More interesting though is that you can access the JavaScript runtime from your C#/VB.NET code and it's pretty easy to do although it's not well documented. Here are a few starter scenarios...

More on GZip compression with ASP.NET Content

Now that GZip is natively available in .NET 2.0 it's very easy to compress your ASP.NET content with GZip compression.

wwHoverPanel ASP.NET AJAX Control updated

I've updated the wwHoverPanel AJAX control to version 1.60. There are a number of new features which are mentioned in this post.

Update to free Web Configuration Utility

I've updated my Web Configuration Utility with better support for IIS 7 and configuring .NET versions for a given Web Virtual.

Building a GZip JavaScript Resource Compression Module for ASP.NET

Finally got around to building a GZip script compression module for my library so I can start to quit worrying so much about script size. Here are some details on the module, how it works and how it's implemented.

Detecting ASP.NET Debug mode

Here's a quickie: How do you detect if an ASP.NET application is running in debug mode?

IIS Root Web and web.config Inheritance - grrrrrr...

While working on a module that installs on a root web I ran - once again - into a problem with the IIS web.config inheritance that causes the root web to propagate handler entries down into sub-virtuals which can cause serious problems.

RegisterClientScriptResource and the Type Parameter

Usage of RegisterClientScriptResource's Type parameter can cause some unexpected behavior if you're using the all to common this.GetType() for a control. If multiple controls share the same resource be sure to use a common type or you might end up with multiple script references in your HTML

Update for the free wwHoverPanel AJAX Control posted

I've posted another update to the free wwHoverPanel AJAX control that provides some useful new functionality and compatibility with MS Ajax.

DataTable/Set/Row support is back in MS Ajax RC

Here are a couple of simple examples of how you can pass data between the server and client and back with MS Ajax using Web Services.

Visual Studio 2005 IntelliSense in ASP.NET pages issue resolved...

I've been fighting with Visual Studio 2005 and Intellisense in ASP.NET pages for some time. As it turns out that

ScriptManager and Resource Compression

The MS Ajax ScriptManager can automatically compress script files when using RegisterClientScriptResource. Unfortunately it only works when a script manager instance sits on a form even though the ScriptManager method is static.

UpdatePanels and ClientScript in custom Controls

Due to changes in the MS Ajax Beta custom controls need to deal with the ClientScript object a bit differently if the control wants to be compatible with the MS Ajax UpdatePanel. It requires using the ScriptManager when available or using ClientScript when not.

Getting tripped by Absolute Positioning in custom Controls

I ran into an issue today with a control that wasn't properly working in the designer when absolute positioning is used and the control couldn't be dragged around the designer surface.

Strongly typed Resources in ASP.NET

If you’ve used WinForms application you might envy the fact that there you get strongly typed resources automatically for your RESX files – the Compiler automatically generates a class that contains each of the resources as a property of the class. Unfortunately this feature isn't available in ASP.NET. Here's why and a utility that can create you strongly typed resources that work.

.NET Web Services and Visual FoxPro COM Object Threading Issues

I ran into an interesting issue today with a couple of ASMX Web Services that act as a front end for Visual FoxPro COM object for a client. The COM objects were blocking at times or worse in some cases cross talking and stepping on each other's environment. Turns out ASMX Web Services don't have an ASPCOMPAT flag so it takes some work to get Web Services to behave with STA components like those from Visual FoxPro

IP6 Addresses and Vista in ASP.NET

Here’s a nice gotcha you might want to think about. Vista ships with IP Version 6 and this may in some situations affect how IP Addresses are returned by your Web applications. As part of my ASP.NET tools I have a request logging module that hooks into the pipeline and picks up and logs IP addresses which promptly started failing with IP6 addresses because they are too long.

ASP.NET Connections Fall 2006 Slides and Samples posted

I’ve posted my slides and samples for my Fall 2006 ASP.NET Connections sessions online.

ASP.NET Connections Wrap-up

Another conference behind me. Phew… I had a ton of fun this week at the Connections conference in Vegas, but as always it’s quite an experience to go through from my end.

My first MSDN Article: A Two-way DataBinding Extender Control for ASP.NET

So I was walking through the trade show here at the Connections conference today and ran by the MSDN booth and there it was: The December issue of MSDN Magazine, and in it my first article for the magazine. Woo hoo. It’s in the December issue and it’s about building the two-way databinding control...

ResourceProvider Localization Sample posted

I’ve been talking for some time about about a localization provider I’ve been working on off and on for my session at ASP.NET Connections next week. I was finally able to post a small sample of what the provider does and what the admin interface looks like as part of my wwHoverPanel AJAX samples. The sample shows resource serving and resource editing in action.

Accessing Localized values in ASP.NET markup and JavaScript

I'm finally getting to the point of actually using my localization provider and localizing a couple of applications, which as we all know is tedious as heck. Here are a few thoughts in how to deal with literal values placed into the ASP.NET page markup, especially in relation to creating script code literals.

Strongly typed resources in ASP.NET

So I was screwing around today with strongly typed resources in ASP.NET. Another cool side-effect of using Web Application Projects as opposed to stock ASP.NET projects is that WAP uses strongly typed global resources. If you create a global resource file, WAP automatically creates a strongly typed...

Auto-Culture detection related issues in ASP.NET

I've been mostly playing around with new Auto-Culture switching in ASP.NET 2.0 and it seems that there are a coulpe of issues I've run into that I can't seem to work around using this mechanism. I’ve posted about ways to switch cultures in code previously and that’s been working fine, but...

Creating and writing ASP.NET 2.0 custom Configuration Sections

I had a few false starts when trying to update a custom Configuration Section in web.config today. It's super easy to create sections and read the values, but writing turned out to be a little more tricky due to lack of documentation.

ListControl SelectedValue inconsistencies

I really dislike the ListControl SelectedValue implementation – this damn property is causing me all sorts of grief on occasion with its inconsistencies.

wwHoverPanel Update to co-exist with MS AJAX

I’ve posted a small update to the wwHoverPanel control today that fixes a couple of small problems if used in combination with MS Ajax beta.

Common Problems with rendering Bitmaps into ASP.NET OutputStream

Rendering image output in ASP.NET is not always straight forward as there are situations where images cannot be directly rendered into the Response.OutputStream

Packaging ASP.NET ASPX Pages into a separate Assembly

I was thinking about deploying some administration pages for a component I've built recently and it came to me that it'd be nice to be able to package the admin pages as part of an assembly rather than forcing installation of a bunch of support files. It turns out using Web Deployment Projects it's possible to accomplish this at least at first glance with very little effort.

Properly overriding the Width Property of Web Control?

If I have a control that inherits say from a Panel control (which basically generates a <div>) and I want to override...

LosFormatter for easy Serialization

Ah, the ASP.NET LosFormatter – it’s a wonderful thing. I’m working on this resource provider and one of the things it has to do is deal with resources other than strings. There are a examples in several places that do a really half assed job of dealing with object resources that either don’t work. The LosFormatter makes this all so much easier.

ResoureProvider, ResourceManagers Relationships in ASP.NET 2.0

 I’ve been chomping away at my custom resource provider/manager and I have most of this working nicely with the ability to dynamically update resource content which was the original goal of this whole process. But even as all of this is coming together I still feel a bit lost on the high...

Odd problem with ASP.NET Caching and a CAPTCHA Control

I've run into an odd problem with a third party Captcha control I use in my app where it appears that the ASP.NET Cache is dumping items almost immediately after they're added.

Recycling an ASP.NET Application from within

In most situations developers want to minimize the amount of ASP.NET Application cycling that occurs, but I've found a few situations where it's actually quite useful to force the ASP.NET application cycle from within the application itself. Here's how...

Trying to implement IImplicitResourceProvider

I'm still trying to implement a custom Localization provider and while I've made the base functionality work fairly easily I'm stuck on the IImplicitResourceProvider interface not being quite sure where it needs to go and what it EXACTLY needs to do. I have it firing but it's not working correctly...

Custom Localization ResourceProviders and Compiler Errors

I’ve been struggling with building a custom ResourceManager and hooking it into ASP.NET over the last few days as part of a localization engine that is data driven rather than through Resources. I’ve had a separate engine for this for sometime, but it hasn’t been hooked into the .NET or ASP.NET...

The type initializer for 'System.Drawing.ToolboxBitmapAttribute' threw an exception.

Whoa, a whacky ASP.NET error showed up on the WebLog Error log sometime this evening generating a boat load of errors rather quickly.

Compilation and Deployment in ASP.NET 2.0 Article posted

I’ve posted a new looong article on Compilation and Deployment with ASP.NET 2.0 in the Articles section of the site. This article also ran in CoDe magazine this month: Compilation and Deployment in ASP.NET 2.0Compilation and deployment in ASP.NET 2.0 has brought some of the biggest changes to the...

Thread Aborted exception with a Thread Timer fired in ASP.NET

I'm working on an app that uses a Thread Timer in an ASP.NET application to fire of a 'scheduled' recurring task that processes some slow running IO requests in a queued fashion. The concept works fine on my dev box, but unfortunately on the live server the timer thread aborts somewhere in the processing...

Web Application Projects and Visual Studio under Vista RC1

I’ve been working for the last couple of days with some code in Web Application Projects under Vista RC1 and I am having nothing but problems with the Visual Studio Web Designer...
West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024