• Westward Bound
  • About Aaron Brander

The Saulzar Codex

~ and other writing by Aaron Brander

The Saulzar Codex

Tag Archives: .NET

Keeping your software young

01 Monday Oct 2012

Posted by Aaron Brander in On Technology

≈ Leave a comment

Tags

.NET, Mindscape, technology

Every once in a while, I look at the date and wonder how fifteen years have passed since I graduated high school.  Looking back at those four adolescent years, they feel more like four decades.  It is crazy to experience the speed of life.

The software we build wonders the same thing. Has it really been seven years since that website was built?  Wasn’t it just yesterday that Ajax was the thing of the future, and IE 7 was the greatest step forward in Internet history (ok, maybe that was never the case).

Time and Technology stop for no man, and it certainly does not stop for the applications we build. So what can we do to keep them fresh and healthy?  It’s not so different from the additional exercise, better diet, and regular checkups that we do for ourselves. In the case of technology, the key is to keep up on blogs, product releases, and to continue to use the application so you can understand its needs.

Microsoft released .NET 4.5  on August 15, 2012, and I was pleased to have a few minutes to install Visual Studio 2012 with .NET 4.5, and give webTRAIN, our Web Marketing Platform, an upgrade.

webTRAIN was built back in 2007 as a .NET 2.0 website using Visual Studio 2005.  Since that time, we have upgraded it to .NET 3.5 and have been using Visual Studio 2008 to code it.  I really have been looking forward to upgrading to .NET 4.0, but I wanted to wait until we had new servers with IIS 7 installed.

We made the move to a new 4 server network with IIS 7 a few months back. With that, we were finally able to consider moving to .NET 4.  I heard .NET 4.5 was around the bend, so it made sense to wait just a bit longer.

The actual process of moving into Visual Studio 2012 and .NET 4.5 was not as painful as I thought it would be.  We have run into two hiccups so far in our testing.

1) .NET 4.5 handles request validation differently that .NET 3.5 and .NET 4.0.  This came up specifically when trying to pass HTML from a Tiny MCE editor to our model.  We found the answer in this whitepaper. The portion that affected us was “Support for unvalidated requests’”, which I have copied below:

*******************************************************************

To allow this, ASP.NET 4.5 now supports unvalidated access to request data. ASP.NET 4.5 includes a newUnvalidated collection property in the HttpRequest class. This collection provides access to all of the common values of request data, like Form, QueryString, Cookies, and Url.

Using the forum example, to be able to read unvalidated request data, you first need to configure the application to use the new request validation mode:

<httpRuntime requestValidationMode="4.5" ...
/>

You can then use the HttpRequest.Unvalidated property to read the unvalidated form value:

var s = context.Request.Unvalidated.Form["forum_post"];

Security Note: Use unvalidated request data with care! ASP.NET 4.5 added the unvalidated request properties and collections to make it easier for you to access very specific unvalidated request data. However, you must still perform custom validation on the raw request data to ensure that dangerous text is not rendered to users.

*********************************************************************

 

2) After updating our development servers to .NET 4.5, webTRAIN seemed fine and dandy. However, we found that it caused an issue with an MVC app that used automatic build and deploy via Team City on our development server. It built the code against .NET 4.5 assemblies and when we deployed it live, where .NET 4.5 is not yet installed, it ran into an error.

The error was:

Could not load type ‘System.Runtime.CompilerServices.ExtensionAttribute’ from assembly ‘mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.

We ended up having to retrieve mscorlib from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 and building it directly into our application.  It required a manual change to the programs’ XML file to include:

<Reference Include=”mscorlib” />
<Reference Include=”System.Core” />

There’s still lots more testing to do to make sure webTRAIN will play nicely with the new updates, but it’s great to know that we can begin to include Strongly Typed Datasets, Model Binding, HTML 5 snippets, and all the other great .NET 4.5 upgrades into our new features.  webTRAIN is feeling younger already!

Have you had luck upgrading to .NET 4.5?

Aaron Brander is the VP of Technology for MINDSCAPE at Hanon McKendry.

Share this:

  • Twitter
  • Facebook
  • More
  • Email

Like this:

Like Loading...

Request.URL–what’s that property?

24 Thursday May 2012

Posted by Aaron Brander in On Technology

≈ Leave a comment

Tags

.NET, technology, work

Request.URL can be used in .NET to get the value that the web browser used to access a page. However, there are many different properties to choose from, and sometimes it is difficult to know which property to use.

I tired of guessing at the correct value and decided to write a small bit of code to display all of the properties so I could find the correct value faster next time.

Here’s what my code looks like:

Imports System.Reflection

Partial Class Tests_requestURL
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim info() As PropertyInfo = Request.Url.GetType().GetProperties()
        For Each a As PropertyInfo In info
            If a.CanRead Then
                Me.ltlValues.Text &= String.Format("{0}: {1}<br><br>", a.Name, a.GetValue(Request.Url, Nothing))
            End If

        Next
    End Sub
End Class

The code uses a bit of reflection and I am sure can be helpful for figuring out the properties of any other object.

For this url:

http://train.mindscapesolutions.com/tests/requesturl.aspx?query1=test&query2=test

The output is:

AbsolutePath: /tests/requesturl.aspx
AbsoluteUri: http://train.mindscapesolutions.com/tests/requesturl.aspx?query1=2&query2=3
Authority: train.mindscapesolutions.com
Host: train.mindscapesolutions.com
HostNameType: Dns
IsDefaultPort: True
IsFile: False
IsLoopback: False
IsUnc: False
LocalPath: /tests/requesturl.aspx
PathAndQuery: /tests/requesturl.aspx?query1=2&query2=3
Port: 80
Query: ?query1=2&query2=3
Fragment:
Scheme: http
OriginalString: http://train.mindscapesolutions.com:80/tests/requesturl.aspx?query1=2&query2=3
DnsSafeHost: train.mindscapesolutions.com
IsAbsoluteUri: True
Segments: System.String[]
UserEscaped: False
UserInfo:

Share this:

  • Twitter
  • Facebook
  • More
  • Email

Like this:

Like Loading...

Vegas, Baby! – Microsoft Developer Conference

19 Monday Apr 2010

Posted by Aaron Brander in On Technology

≈ Leave a comment

Tags

.NET, Microsoft, work

Vegas, baby! I had the opportunity to attend the Microsoft Visual Studio 2010 and ASP.NET 4.0 Launch conference in Las Vegas from April 12-14, 2010 (http://www.devconnections.com/shows/SP2010ASP/default.asp?s=142).  I thought I’d post a few technical and travel notes from the conference for those of you (and I imagine that’s most of you) who couldn’t make it.  Let’s do a Clint Eastwood theme for this blog: The Good, The Bad, and The Ugly

Work Stuff

The Good

  • The Keynote address on the first day was held in the Grand Ballroom at the Bellagio. It’s a huge room and there were a lot of people in attendance to see what was going on with Visual Studio and ASP.NET 4.0. Here are a few quick items from my notes:
    • VS has a lot of new improvements for efficiency like intellisense for jQuery, code visualization features to get a sense of a project and dependencies from a high level, improved debugging and profiling help
    • A bug assignment process that lets a tester record their process, and the developer to debug the exact process the tester went through
    • Some new controls including a chart control
    • Windows 7 Phone, MVC, and Sharepoint are more closely integrated with Webforms and Winforms. If you can program in those technologies, you can do it in other the other .NET technologies
  • Later the first day there was a great “What’s New” class.
    • Viewstate optimization: Now you can turn View State on and off by control to reduce the overall size of Viewstate on a page.
    • Client Ids – no more weird, VS named controls. Now you can determine what you want the IDs to be.  Great for new applications, but may prove difficult to update your existing controls
    • .NET controls now generate standards based, css friendly HTML. That’s a big difference from the table based junk that used to be generated by controls such as the list and grid view.
    • URL routing is supported out of the box.  We’ve built our own custom FileNotFound based URL routing already. I’m not sure if it would be worth the hassle to rewrite the entire platform, but it may make some file or product specific URL handling easier on our webTRAIN platform.
    • HTML Encoding shortcut. Replace <%= with <%: and everything within the brackets will be HTML encoded automatically.
    • Built in Charting controls. Sweet! This was released as a separate component in 2008, so some of you may know it already. Now it is a standard part of Visual Studio. (http://www.4guysfromrolla.com/articles/072209-1.aspx)
    • Editing box – an easy way to edit multiple rows at the same time. (http://msdn.microsoft.com/en-us/library/dd465268.aspx)
    • Navigate To – no more copying a function name and then using the Find command on the entire project to see where it is in use. Now you can use the Navigate To feature to display all methods and events in the project. Just start typing and the list will auto update. Click on a result to go to the correct spot in the code. Nice!
    • Ajax 4.0 and jQuery are now more tightly integrated. When you create a new project in Visual Studio, it will import in the jQuery library so you can get started right away.  It also includes baked in intellisense for jQuery. The jQuery is actually interpreted on the fly and the intellisense adjusted to the appropriate context.
  • Having very little jQuery experience myself, I learned a lot of jQuery basics at the seminar. I don’t think I’m scared of it anymore! I think it’s time to start dabbling in it and see what I can do.
  • The Bellagio is amazing!  (http://www.bellagio.com/)
  • The Geekfest that Microsoft hosted at the Jet nightclub was pretty amazing.  Check the travel report later this week for more information on it.

    The Bad

    • There were a lot of jQuery and Ajax sessions on the schedule, and Jason and I were keen to take in them all. However, after the first day, they all started to be the same. We were hoping that they would get more in depth; in fact, one of the Visual Studio tracks had a multi-session desktop course that looked like it went pretty deep.  That wasn’t the case with Ajax. Jason, a seasoned jQuery user and early adapter of VS 2010, learned a few things, but mostly the sessions served to give him more confidence that he was doing things the right way.
    • We needed a backup plan and didn’t have one.  We kept trying more and more Ajax and jQuery courses and finding that most of the material was repeated.  At one session, a presenter told us we may as well leave if we had taken a particular course earlier in the day.  We checked our notes, saw that we had been said course, and headed to lunch early. A deeper coding experience would have been nice. It looked like it worked that way on the schedule.

    The Ugly

    • It only happened once, but there was a presenter that was so poorly prepared and such a bad speaker that we actually left the course early. I didn’t like having power point slides read to me in college, and it turns out I still don’t like that.  Luckily (or unluckily, depending on how you want to view it), the same material was covered in the next session we went to.
    • The last day of the conference was very light on content that we were interested in. It made for a very long day.

    So what did we learn?  Visual Studio 2010 and .NET 4.0 have a lot of great tools that we are looking forward to using. We also learned that we can’t expect deep content next time we go, and so we should be prepared to go to sessions that don’t necessarily have anything to do with what we are working on currently. In retrospect, we should have gone to more MVC and Silverlight sessions instead of stubbornly wishing for more Ajax and jQuery information that just wasn’t forthcoming.

    Look for the travel portion of this blog later this week.

    Share this:

    • Twitter
    • Facebook
    • More
    • Email

    Like this:

    Like Loading...

    Categories

    • On Books
    • On Miscellany
    • On Technology
    • On Travel
    • On Writing

    Get Social


    My Links

    • Brander Photography
    • Libzig.com
    • Mike July.com
    • Mindscape @ Hanon McKendry
    • Picture Perfect
    • Westward Bound

    .NET 1 star 2 stars 3 stars 4 stars 5 stars 90 day challenge African Mythology Alexander the Great Basketball Bernard Cornwell Bob Lee Swagger China Coming Soon Dan Brown Danes David Gemmell diet Dresden Files Fantasy Fencing Fiction Final Four fitness Gladiators golf books golf practice Google Halo Hiking Historical Fiction History HTML James Clavell Japan Jim Butcher Kindle King Alfred Last of the Mohicans Lord of the Rings Magic Michigan State Spartans Microsoft Mindscape Neil Gaiman Non-Fiction Norse Mythology On Books programming Project Management Putting R.A. Salvatore ratings Richard Sharpe Roman Empire Roman History Romans Rome Samurai Saulzar Saulzar Codex Saxons Science Fiction Shattered Sports Books Stalin Stephen King technology Tolkien Travel Washington D.C. Wizards work Work in Progress Writing

    Create a free website or blog at WordPress.com.

    Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
    To find out more, including how to control cookies, see here: Cookie Policy
    • Follow Following
      • The Saulzar Codex
      • Join 33 other followers
      • Already have a WordPress.com account? Log in now.
      • The Saulzar Codex
      • Customize
      • Follow Following
      • Sign up
      • Log in
      • Report this content
      • View site in Reader
      • Manage subscriptions
      • Collapse this bar
    %d bloggers like this: