Articles : Page 7 of 13
- Filter:
- Url
-
Changing Base Type Of A Razor View
Feb 1121Within a Razor view, you have access to a base set of properties (such as Html, Url, Ajax, etc.) each of which provides methods you can use within the view. For example, in the following view, we use the Html property to access the TextBox method. @Html.TextBox("SomeProperty") Html is a property of type HtmlHelper and there are a large number of useful extension methods that hang off this type, such as TextBox. But where did the Html property come from? It’s a property of System.We...
-
Routing Regression With Two Consecutive Optional Url Parameters
Feb 1120It pains me to say it, but ASP.NET MVC 3 introduces an ugly regression in routing from ASP.NET MVC 2. The good news is that there’s an easy workaround. The bug manifests when you have a route with two consecutive optional URL parameters and you attempt to use the route to generate an URL. The incoming request matching behavior is unchanged and continues to work fine. For example, suppose you have the following route defined: routes.MapRoute("by-day", "archive/{month}/{day}", new { contro...
-
Html.Awkward
Feb 1117I’ve seen the HTML helpers in ASP.NET MVC drive developers to madness. For example: @Html.ActionLink("Detail", "Detail", "Car", new { id = 5 }) ... produces ... <a href="/Home/Detail?Length=3" id="5">Detail</a> Notice "Length=3" in the query string? That's probably not what you expected. We see this output because we are calling the ActionLink overload where “Car” is interpreted as route data and the anonymous object we want to use for route data is instead interpreted as the HTML...
-
Authenticate Orchard users with AppFabric Access Control Service
Feb 1114From the initial release of Orchard, the new .NET CMS, I have been wondering how difficult (or easy) it would be to integrate external (“federated”) authentication like Windows Azure AppFabric Access Control Service with it. After a few attempts, I managed to wrap-up a module for Orchard which does that: Authentication.Federated. After installing, configuring and enabling this module, Orchard’s logon page is replaced with any SAML 2.0 STS that you configure. To give you a quick idea of what ...
-
Redirecting Routes To Maintain Persistent URLs
Feb 1103Over a decade ago, Tim Berners-Lee, creator of the World Wide Web instructed the world know that cool URIs don’t change with what appears to be a poem, but it doesn’t rhyme and it’s not haiku. What makes a cool URI? A cool URI is one which does not change. What sorts of URI change? URIs don't change: people change them. In a related article, URL as UI, usability expert Jakob Nielsen lists the following criteria for a usable site: a domain name that is easy to remember and easy to spell...
-
Building a Self Updating Site Using NuGet
Jan 1116For those of you who enjoy learning about a technology via screencast, I’ve recorded a video to accompany and complement this blog post. The screencast shows you what this package does, and the blog post covers more of the implementation details. A key feature of any package manager is the ability to let you know when there’s an update available for a package and let you easily install that update. For example, when we deployed the release candidate for NuGet, the Visual Studio Extension M...
-
Hey .NET Developers! Its Christmas All Over Again!
Jan 1114Today was a great day to be a .NET developer. I felt like a five year old on Christmas morning. I had that feeling you get when you just finished opening all your gifts and you are not sure what you want to play with first. Just in case you are living under a rock, here is a quick summary of what I found under the Christmas tree today. MVC 3 – Its Finally Here Today MVC3 with Razor was released. This means that we can finally avoid paying the angle bracket tax. The new razor syntax will mak...
-
ASP.NET and HTML5 Local Storage
Jan 1112My favorite feature of HTML5, hands-down, is HTML5 local storage (aka DOM storage). By taking advantage of HTML5 local storage, you can dramatically improve the performance of your data-driven ASP.NET applications by caching data in the browser persistently. Think of HTML5 local storage like browser cookies, but much better. Like cookies, local storage is persistent. When you add something to browser local storage, it remains there when the user returns to the website (possibly days or month...
-
Grouping Routes Part 2
Jan 1109In part 1 of this series, we looked at the scenario for grouping routes and how we can implement matching incoming requests with a grouped set of routes. In this blog post, I’ll flesh out the implementation of URL Generation. Url Generation Implementation URL generation for a group route is tricky, especially when using named routes because the individual routes that make up the group aren’t in the main route collection. As I noted before, the only route that’s actually added to the rout...
-
Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications
Jan 1106I got an interesting question recently from a gentleman who has an existing ASP.NET WebForms 2.0 application that works just fine. He's upgraded it to ASP.NET 4 and it still works great, but now he wants to add some ASP.NET MVC pages to it. He doesn't want to rewrite the application. A few years ago I did a post on Hybrid ASP.NET applications. The goal was to reinforce the point that you can have ASP.NET applications that are both WebForms and MVC (as well as WCF and ASMX Web Services and o...

