Rick Strahl's Web Log
Wind, waves, code and everything in between...
Ad-free experience sponsored by:
- 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 MVC
October, 2017 (2)
September, 2017 (6)
August, 2017 (1)
July, 2017 (3)
June, 2017 (2)
May, 2017 (2)
April, 2017 (4)
March, 2017 (5)
February, 2017 (2)
January, 2017 (4)
December, 2016 (5)
November, 2016 (4)
October, 2016 (4)
September, 2016 (5)
August, 2016 (1)
July, 2016 (1)
June, 2016 (6)
May, 2016 (6)
April, 2016 (4)
March, 2016 (3)
February, 2016 (2)
January, 2016 (5)
December, 2015 (1)
November, 2015 (3)
Visual Studio (44)
ASP.NET Core (21)
Web Services (19)
Web Api (16)
Sql Server (8)
Microsoft AJAX (8)
Web Connection (7)
West Wind Ajax Toolkit (7)
Entity Framework (6)
Html Help Builder (5)
Live Writer (5)
Visual Studio (5)
Source Control (4)
Help Builder (3)
Internet Explorer (3)
Internet Explorer (3)
Web Browser Control (3)
Software Development (3)
.NET Core (2)
.NET Core (2)
ASP.NET vNext (2)
Dynamic Types (1)
Control Development (1)
Markdown Monster (1)
ASP.NET Markdown (1)
.NET Standard (1)
ASP.NET Core (1)
Markdown Monster (1)
Visual Studio Code (1)
Web Deployment Projects (1)
Web Design (1)
Serving URLs with File Extensions in an ASP.NET MVC Application
November 13, 2015 - Maui, HI
I ran into an issue trying to create a specific file URL for Windows Live Writer in an MVC application, where I needed to return a very specific file based URL with an extension from an MVC application. Turns out that this is not as easy as it sounds.
Rebooting Database Localization for ASP.NET with West Wind Globalization 2.0
June 23, 2015 - Hood River, OR
I'm happy to announce the release of Westwind.Globalization version 2.0 - a database resource localization library for ASP.NET. Version 2 is a major upgrade that includes many new features including support for new database providers, a brand new Web Resource Editor, much improved ASP.NET MVC support, vastly better support for importing and exporting Resx resources, creating of strongly typed classes and much more. There's also a new video that describes features and provides a getting started guide with some detailed background. In this post I review some of the new features and point at additional resources for more information.
401 Response from ASP.NET Identity when linking to External Accounts
May 05, 2015 - Hood River, OR
A couple of days ago I ran into an odd problem where all of my external ASP.NET Identity providers would fail to redirect to the external provider login URLs. Instead the app fired empty 401 requests without any other indication of failure. It turns out this was a misconfiguration issue, but it took a bit to track this down due to the fact that there's no error trapping and no error information. Here's more info on this edge case failure.
Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application
April 29, 2015 - Maui, HI
ASP.NET 4 provides a new Identity Authentication/Authorization framework that's very comprehensive and works reasonably well for new applications. However, if you have existing applications or use custom user management, it's not very clear how to use just the basic OWIN Authentication/Authorization layer without the full UserManager and Entity Framework implementation. In this post I describe how to use the bare minimum Identity features to hook up a custom domain model for both local and external logins in an ASP.NET MVC application.
ASP.NET MVC HttpVerbs.Delete/Put Routes not firing
April 09, 2015 - Maui, HI
If you're using ASP.NET MVC to build API endpoints in your application you might have run into a problem where the PUT and DELETE HTTP operations don't work - you get a 404 instead. Turns out that the IIS default configuration doesn't include the verbs for a required handler. Here's what the problem is, and how to fix it if it hits you.
ASP.NET MVC, Localization and Westwind.Globalization for Db Resources
March 17, 2015 - Maui, HI
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.
Project Navigation and File Nesting in ASP.NET MVC Projects
June 30, 2014 - Hood River, OR
Project navigation in large projects can be a pain as you have to sift through large amounts of files. I found myself re-organizing projects in a few different ways to make project navigation easier. In this blog post I share a few different approaches as well as some useful tooling to improve my daily workflow.
A dynamic RequireSsl Attribute for ASP.NET MVC
June 18, 2014 - Hood River, OR
In ASP.NET MVC the RequireHttps attribute allows for securing controllers and controller methods, but it's limited to either on or off statically. In this post I discuss a custom attribute that can dynamically set SSL usage based on a configuration setting or delegate.
Creating ASP.NET MVC Negotiated Content Results
May 20, 2014 - Hood River, OR
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.
IIS Default Documents vs. ASP.NET MVC Routes
August 15, 2013 - Hood River, OR
ASP.NET MVC's routing takes over extensionless URLs and if you want to serve static default document using IIS's default settings you need to make sure you ignore the default route.
Rendering ASP.NET MVC Razor Views outside of MVC revisited
July 15, 2013 - Pag, Croatia
Rendering ASP.NET MVC Views outside of the context of MVC can be immensely useful for various administration, error and logging tasks. Luckily there are some easy ways to render MVC even outside of an MVC controller. Here's some information on how to make that happen.
Using HTML 5 SessionState to save rendered Page Content
July 01, 2013 - Hood River, Oregon
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.
Rendering ASP.NET MVC Views to String
May 30, 2012 - Hood River, Oregon
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
May 16, 2012 - Maui, Hawaii
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.
GZip/Deflate Compression in ASP.NET MVC
April 28, 2012 - Maui, Hawaii
If you want to create ASP.NET MVC content that uses gzip or deflate compression you need to use some custom code. Here's an action filter that compresses content in your ASP.NET MVC applications.
ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
April 20, 2012 - Maui, Hawaii
Today I discovered an MVC behavior I hadn't noticed: For HTML helper controls MVC always uses POSTBACK values to display the control value rather than model values when the View is rendering in a POST back. In effect this means that MVC Views can't update the value of controls during a POST back using the standard HTML Helper Controls.
Odd MVC 4 Beta Razor Designer Issue
April 14, 2012 - Maui, Hawaii
I have an odd designer issue with MVC 4 Razor pages which are causing errors in the environment.
Physical Directories vs. MVC View Paths
April 05, 2012 - Maui, Hawaii
Physical directories that map paths that are also mapped by ASP.NET MVC routes can cause some consternation, especially if you're not aware that there's pathing overlap between the two. This post is a story about an operator error episode of an accidental file move that took a while to trace down due physical path interference.
Using the HTML5 <input type="file" multiple="multiple"> Tag in ASP.NET
March 06, 2012 - Maui, Hawaii
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.
Getting a Web Resource Url in non WebForms Applications
October 05, 2011 - Hood River, Oregon
Need to retrieve Web Resource Urls from a .NET assembly, but not running in WebForms? Here's how you can create a small helper function that lets you retrieve WebResourceUrls from Razor or MVC applications.
Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth
September 17, 2009 - Hood River, Oregon
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.
Odd/Even Looping in ASP.NET MVC
August 31, 2009 - Hood River, Oregon
Creating lists that have alternating display characteristics for alternating content are common and in MVC you have to do a little bit more work to make this happen. Here's an easy way to represent the expression using a boolean variable.
WebResource access in ASP.NET MVC
July 30, 2009 - Saalfelden, Austria
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.
July 21, 2009 - Hood River, Oregon
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
July 19, 2009 - Hood River, Oregon
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.