WebLog Posts in Category MVC


Project Navigation and File Nesting in ASP.NET MVC Projects
June 30, 2014 @ 10:28pm

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.

13 comments
A dynamic RequireSsl Attribute for ASP.NET MVC
June 18, 2014 @ 1:37am

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.

6 comments
Creating ASP.NET MVC Negotiated Content Results
May 20, 2014 @ 9:13pm

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.

8 comments
IIS Default Documents vs. ASP.NET MVC Routes
August 15, 2013 @ 8:38pm

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.

5 comments
Rendering ASP.NET MVC Razor Views outside of MVC revisited
July 15, 2013 @ 1:48pm

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.

7 comments
Using HTML 5 SessionState to save rendered Page Content
July 01, 2013 @ 3:46pm

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.

3 comments
Rendering ASP.NET MVC Views to String
May 30, 2012 @ 1:53am

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

12 comments
DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 9:44am

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.

10 comments
GZip/Deflate Compression in ASP.NET MVC
April 28, 2012 @ 4:00am

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.

4 comments
ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
April 20, 2012 @ 2:19am

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.

23 comments
Odd MVC 4 Beta Razor Designer Issue
April 14, 2012 @ 12:54pm

I have an odd designer issue with MVC 4 Razor pages which are causing errors in the environment.

4 comments
Physical Directories vs. MVC View Paths
April 05, 2012 @ 2:38pm

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.

5 comments
Using the HTML5 <input type="file" multiple="multiple"> Tag in ASP.NET
March 06, 2012 @ 1:54am

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.

7 comments
Getting a Web Resource Url in non WebForms Applications
October 05, 2011 @ 3:29am

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.

3 comments
Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth
September 17, 2009 @ 9:15pm

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.

39 comments
Odd/Even Looping in ASP.NET MVC
August 31, 2009 @ 8:54pm

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.

17 comments
WebResource access in ASP.NET MVC
July 30, 2009 @ 3:21am

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.

16 comments
Introducing CodePaste.NET
July 21, 2009 @ 3:28am

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.

24 comments
Url.Action() and RouteValue Encoding
July 19, 2009 @ 5:21pm

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.

11 comments


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2014