Articles : Page 1 of 1

  • Abstracting away issues of HttpContext from your ASP.NET MVC controllers

    Abstracting away issues of HttpContext from your ASP.NET MVC controllers

    Feb 12
    03

    I've noticed that I write software in one of three modes: For myself: Shortcuts, less testing, not well-factored. For myself but in public: Mostly POP Forums, which I try to avoid letting it suck since others will use it and see the code. For sharing: Any day job or gig where others will use or maintain your code. You don't want to unleash crapsauce on others. I have to admit that second case isn't the most clean of endeavors. While I'm generally happy with the forum app and the feedba...


  • How to access controller methods from a view in ASP.NET MVC

    How to access controller methods from a view in ASP.NET MVC

    Jul 11
    30

    This question has been posed in several places. One of the places is on StackOverflow here. The use case here is that my controller has important state or an important function, and I’d like to leverage it from the view. It’s not appropriate to factor out to an html helper or other view-based utility class. It is something unique to the controller. It would be very easy to just pass the controller over to the view so that the view could make use of its methods, but there is a lot of discussion...


  • Delegate feed privileges to other users on MyGet

    Delegate feed privileges to other users on MyGet

    Jun 11
    29

    One of the first features we had envisioned for MyGet and which seemed increasingly popular was the ability to provide other users a means of managing packages on another user’s feed. As of today, we’re proud to announce the following new features: Delegating feed privileges to other users – This allows you to make another MyGet user “co-admin” or “contributor” to a feed. This eases management of a private feed as that work can be spread across multiple people. Making private feeds privat...


  • A Better Razor Foreach Loop

    A Better Razor Foreach Loop

    Apr 11
    14

    Yesterday, during my ASP.NET MVC 3 talk at Mix 11, I wrote a useful helper method demonstrating an advanced feature of Razor, Razor Templated Delegates. There are many situations where I want to quickly iterate through a bunch of items in a view, and I prefer using the foreach statement. But sometimes, I need to also know the current index. So I wrote an extension method to IEnumerable<T> that accepts Razor syntax as an argument and calls that template for each item in the enumeration. pub...


  • March 6th Links: ASP.NET, ASP.NET MVC, jQuery, EF, .NET

    March 6th Links: ASP.NET, ASP.NET MVC, jQuery, EF, .NET

    Mar 11
    07

    Here is the latest in my link-listing series. Also check out my Best of 2010 Summary for links to 100+ other posts I’ve done in the last year. [I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu] ASP.NET 35 ASP.NET and VS 2010 What’s New Videos: 35 free videos from Joe Stagner that highlight some of the new features that came in ASP.NET 4 and VS 2010. Filling in PDF Forms with ASP.NET and iTextSharp: Nice article by Scott Mitchell on ...


  • Defining Default Content For A Razor Layout Section

    Defining Default Content For A Razor Layout Section

    Mar 11
    05

    Layouts in Razor serve the same purpose as Master Pages do in Web Forms. They allow you to specify a layout for your site and carve out some placeholder sections for your views to implement. For example, here’s a simple layout with a main body section and a footer section. <!DOCTYPE html> <html> <head><title>Sample Layout</head> <body> <div>@RenderBody()</div> <footer>@RenderSection("Footer")</footer> </body> </html> In order to use this layout, your view might look like. @{ Layout ...


  • Templated Razor Delegates

    Templated Razor Delegates

    Feb 11
    27

    David Fowler turned me on to a really cool feature of Razor I hadn’t realized made it into 1.0, Templated Razor Delegates. What’s that? I’ll let the code do the speaking. @{ Func<dynamic, object> b = @<strong>@item</strong>; } <span>This sentence is b("In Bold").</span> That could come in handy if you have friends who’ll jump on your case for using the bold tag instead of the strong tag because it’s “not semantic”. Yeah, I’m looking at you Damian . I mean, don’t both words signify being ...



  • 1