ASP.NET

Archived Posts from this Category

The Morning Brew #990

Posted by on 28 Nov 2011 | Tagged as: .NET, ASP.NET, COM Interop, Development, Morning Brew, Photography

Disaster struck this morning – I pressed post, waited until the page reloaded and shut my laptop as usual, but for reasons unexplained the post never made it onto the site – So here is today’s edition, a little later than planned – at least its still morning *somewhere* in the world!

Thanks to Libor or letting me know something was wrong

Update: In my haste to resurect today’s post a ‘smart quote’ snook into some HTML merging Sankarsan & Jon Skeets links together – fixed now – thanks to EF for letting me know

Software

  • Simple.Data for Mono – Mark Rendle has got his Simple.Data Dynamic Data Access library up and running under Mono, with most of the tests passing. The Mono release is available as a tgz download from the project’s GitHub Site.

Information

  • New Bundling and Minification Support (ASP.NET 4.5 Series) – Scott Guthrie continues his series of posts looking at the new features of ASP.NET 4.5, currently available in the Developer Preview Release. In this post Scott discusses the new support for bundling and minification of CSS and JavaScript Resources.
  • Inside ASP.NET 4.5 Bundling and Minification – Sankarsan discusses some of the details behind the Bundling and minification, looking at how the functionality is implemented in the framework, discussing how the functionality is called and the interactions between the parts.
  • Eduasync part 17: unit testing – Jon Skeet continues his exploration of the Async / Await functionality of C#5 discussing how it is possible to unit test async code (sometimes), illustrating by showing and discussing some of the tests for his Majority Voting implementation.
  • Razor Donut Caching – Phil Haack discusses the possible look and feel for the re-introduction of donut caching in ASP.NET MVC4, highlighting a package available for MVC3 which adds the functionality and discussing some of the limitations and possible changes to Razor to make creating donut holes easy.
  • REPL for the Rosyln CTP 10/2011 – Chris Sells discusses the Roslyn CTP release and the Read Evaluate Print Loop (REPL) environment, looking into creating a console based REPL environment using Roslyn, showing how easy executing lines of code becomes with Roslyn.
  • Reflection, performance and runtime code generation – Ivan Towlson discusses the use of reflection and code generation with regard to the performance of code where you need to work with types you don’t know at compile time.
  • Building F# Solutions in Visual Studio 11 &
    Traffic Cop – Fresh Brewed Code, a new blogging community site for developers kicks off with posts from Dan Mohl highlighting resources for working with F# in Visual Studio 11, and Jim Cowart sharing an implementation he calls Traffic Cop for situations where he needed to avoid multiple jQuery Ajax requests for the same resources.
  • Method Stubs – Phil Trelford discusses Test Driven Development in F#, focusing particularly on how you don’t need frameworks to implement stubs and spies in F#.
  • 31 Days of Mango | Day #26: Background File Transfer , Day #27: Microphone API &amp Day #28: Media Library – Jeff Blankenburg’s series of posts on Windows Phone Mango continues with three more guest posts, first another from Gary Johnson discussing background file transfer. Next Parag Joshi discusses the Microphone API and the recording of audio, and finally Jeff Fansler takes a look at the Media Library.
  • 10 Laps around Silverlight 5 (Part 7 of 10) – Michael Crump continues his Silverlight 5 series with part 7 exploring operating system integration with a look at power awareness, 64 bit browser support and Save Dialogs.

Community

  • NxtGenUG – Santa Westley – Liam Westley joins the NxtGenUG in Coventry of their User Group meeting on Monday 12th December. There are no details of the session to be delivered, but Liam is an excelent speaker, and will nodoubt be brings some swat and probably some tasty treats too!

Relocating Temporary ASP.NET Files

Posted by on 15 Oct 2007 | Tagged as: .NET, ASP.NET, Development, IIS, SysAdmin

When you first request a page from the an ASP.NET application, the .NET framework takes the ASPX file and generates code to actually execute the page. This code is then compiled by the framework and the results of the compilation are stored in the Temporary ASP.NET files directory within the framework directory (usually located in c:\windows\Microsoft.NET\Framework). When the ASPX of the compiled DLL changes this code is re-generated and recompiled.
On a server that hosts lots of ASP.NET applications this store of temporary compiled code can occupy a considerable amount of space. On machines with a limited amount of space on their OS partition this can begin to cause problems. Thankfully the ASP.NET framework does allow the location of this directory to be specified as a custom location.
As with most server wide settings you need to make a change to the Machine.Config (for .NET 1.1) or Machine wide web.Config (for .NET 2). The crucial part of the configuration is the Compilation element within system.web. The compilation element has an optional attribute called tempDirectory that allows a new directory location to be specified overriding the default setting of %FrameworkInstallLocation%\Temporary ASP.NET Files.


   
      ...
   

One thing to watch out for when making this change is the file permissions on your new Temporary ASP.NET files – copying the permissions from the original location will do the trick nicely.

Invalid XML from a .NET web service

Posted by on 01 Oct 2007 | Tagged as: .NET, ASP.NET, C#, Development, Web Services, XML

10187684_78f140f0e2_m.jpg
Image Credit: kevinzim on Flickr

One of my basic assumptions about the .NET framework was proved incorrect last week. Up until then, I had believed that when you are using the built in framework classes for exposing web services you were always safe when it came to the output being valid XML. Sadly that turns out to be untrue, and to make matters worse, .NET will happily output XML over a web service even its own .NET web service clients can’t read.

There are certain characters that are forbidden from being in XML as per the official specification. These characters are the low ascii characters such as NULL, EOF etc. Its important to note that this is not a case of unescaped/unencoded versions of this character being disallowed, the encoded characters are also disallowed.

The problem with this isn’t that the .NET framework doesn’t understand these rules – it manages just fine when it comes to acting as a client to a web service serving these characters in content, throwing nice exceptions explaining that these characters are invalid. Additionally, the XML Text Reader has a property ‘Normalization’ which causes the XML reader to be more liberal and ignore invalid characters – but this option is not used within the automatically generated Web Service Client.

This problem isn’t limited to just the web services, standard XML serialisation also experiences the same problems. Here are bits of code that illustrate the problem:

[WebMethod()]
public string InvalidCharacter()
{
   return "" + (char)4;
}

public class MyClass
{
   public string Test = "" + (char)0;
   public static void Main()
{
     MyClass c = new MyClass();
     System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(MyClass));
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     System.IO.StringWriter sw = new System.IO.StringWriter(sb);
     xs.Serialize(sw, c);
     Console.WriteLine(sb.ToString());
    
     System.IO.StringReader sr = new System.IO.StringReader(sb.ToString());
     try
     {
         c = (MyClass)xs.Deserialize(sr);
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.ToString());
}
}
}

The little console application gives output like this:



  

System.InvalidOperationException: There is an error in XML document (3, 12).
System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character.
Line 3, position 12.

Unfortunately I haven’t yet found a fix for this – my only solution is to work around the problem by ensuring that these invalid characters can’t get into the system in the first place or clean the text on the get of each property of the serialized objects.

Things like this really worry me – our frameworks shouldn’t be outputting things that they can’t read – let alone outputting things that completely contravene the specifications. As always, any suggestions on an alternative solution to this problem are welcome.

« Previous PageNext Page »