Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs
Contact   •   Articles   •   Products   •   Support   •   Search
Ad-free experience sponsored by:
ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more

WebLog Posts in Category ASP.NET

A Literal Markdown Control for ASP.NET WebForms

Spent some time last night creating a small ASP.NET Server control that can render literal Markdown text inside of ASPX pages and turn the literal text into Markdown. It's a very simple control, but it makes it lot easier to edit documents that contain simple formatted text content without having to deal with angle brackets for lengthier text.

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.

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.

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

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.

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.

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

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.

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.

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...

GoDaddy and SocketPermissions

So I just got off the phone with support at GoDaddy for one of my customers and was told "Sorry we can't do that", when asked to provide socket permissions to go out and hit a POP3 server. GoDaddy has the web.config locked down and so you can't override the originUrl="site" so my customer is dead...

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 - 2018