Sonntag, 19. Februar 2012

ASP.NET MVC 4 Beta veröffentlicht

Letztes Jahr zur Build wurde die neue Version des ASP.NET MVC Frameworks in der Version 4 angekündigt und ein Developer Preview veröffentlicht. Jetzt steht die Beta-Version von  ASP.NET MVC 4 unter ASP.NET zum Download bereit. Gegenüber dem Developer Preview sind einige wichtigen Punkte hinzugenommen und insbesondere die Unterstützung der Entwicklung von mobilen Applikationen wurde ausgebaut.
Die wichtigsten Neuerungen gegenüber dem Developer Preview sind:

ASP.NET Web API

Mit der ASP.NET Web API steht ein Framework zur Verfügung, um mit den bekannten Paradigmen von ASP.NET MVC mit beliebigen Web Services auf einfache Art und Weise zu kommunizieren. Dazu bietet die ASP.NET Web API ein einfaches Programmiermodell, um HTTP Requests und Responses direkt zu manipulieren und gegen ein streng typisiertes Datenmodell (domains) zu binden. Des weiteren unterstützt die ASP.NET Web API Routing, wie man dies von ASP.NET MVC
gewohnt ist. Ein weiteres schönes Feature ist die Verwendbarkeit von IQueryable<T> als Return-Type, die es ermöglicht auf die Services mit normaler OData Syntax zuzugreifen.
 
Weitere Infos zur ASP.NET web API sind hier zu finden.

Verbesserungen für die Razor Engine

Die Razor Engine versteht jetzt die “~”-Syntax für Verlinkungen (Z.B. <script> src=”~/Scripts/Site.js” />) und unterstützt bedingtes Attribut Rendering. So wird z.B. die Angabe der Style Class im Ausdruck <div class=”@myClass”>Inhalt</div> bei myClass=null auch nicht mehr gerendert.
 

NuGet Integration in MVC-Projekte

Das ASP.NET MVC 4 Projekt-Template bietet jetzt die Verwendung des NuGet Package Restore Features. Aktiviert man diese Option in der Solution werden nicht mehr die Binaries der NuGet Packages in ein Source Control System übernommen, sondern im Build Prozess wird geprüft, ob alle Packages in der entsprechenden Version gemäß der packages.config vorhanden sind und dann ggf. heruntergeladen.
 

Templates für mobile Applikationen

Das neue Projekt-Template für mobile Applikationen basiert auf dem Open Source Framwork jQuery Mobile und enthält bereits die Referenzen auf die KnockOut und Modernizer JavaScript Bibliotheken, die durch NuGet Packages in der aktuellen Version zur Verfügung gestellt werden. Insgesamt merkt man, das viel in der aktuellen Beta-Version von ASP.NET MVC zur Unterstützung der Entwicklung von mobilen Applikationen getan wurde.
 
Mittels der neuen Display Modes können darüber hinaus gemischte Web-Seiten für konventionelle Webseiten und touch-basierte Applikationen entwickelt werden.Legt man beispielsweise in einem Shared View-Folder die Datei _MyPartial.cshtml und _MyPartial.mobile.cshtml ab, wird beim Aufruf über einen mobilen Browser automatisch die mobile Version aufgerufen. Über die DisplayModeProvider-Klasse können sogar noch eigene Display Modes in Abhängigkeit vom UserAgent z.B. für das iPad definiert werden.
 

Fazit

Insgesamt bietet die Beta-Version von ASP.NET MVC 4 wieder sehr viele Bereicherungen, die es uns noch leichter macht mittels des bewährten MVC Pattern unter Ausnutzung der einfachen Razor-Engine traditionelle aber auch touch-basierte Web-Applikationen für den Anwender bereitzustellen.

Weiterführende Links

 
Share |

Sonntag, 16. Oktober 2011

Windows Phone 7: Issue with Textblock and Textbox rendering

There is an issue with Silverlight for Windows Phone if you try to show a Textblock or Textbox with a lot of text. In my current Windows Phone 7 project with have a listbox with comments and with large text sizes (above 3300 in our test cases) we have the effect that the space for the text is rendered but not all characters.

The result looks like this:

 image

This happens if the surrounding container object (for example Grid or Stackpanel) has a defined width and the Textbox or Textblock has the VerticalAlignment set to “Stretch”.

The XAML definition looks like this:

   1:  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
   2:              <ListBox x:Name="MainListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged">
   3:                  <ListBox.ItemTemplate>
   4:                      <DataTemplate>
   5:                        <StackPanel Margin="0,0,0,17" Width="432" >
   6:                            <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
   7:                            <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" 
   8:                                       VerticalAlignment="Stretch"
   9:                                       Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
  10:                        </StackPanel>
  11:                      </DataTemplate>
  12:                  </ListBox.ItemTemplate>
  13:              </ListBox>
  14:   </Grid>

The workaround for this problem is to truncate the text after 3300 characters or don’t use a fix width for the container of the Textbox or Textblock element.

The behaviour is the same in Windows Phone 7.0 and Windows Phone 7.1 projects.

Share |

Samstag, 15. Oktober 2011

Windows Phone 7–Mango süßsauer

Windows Phone Mango

 

Mein neuster Artikel in der Mobile Technology ist seit Freitag an den Kiosken erhältlich. Entgegen des Arbeitstitels “Mango süßsauer” geht es hier nicht um asiatische Kochspezialitäten, sondern um eine kurze Darstellung der neusten Features für  Entwickler bei Nutzung der Windows Phone Developer Tools 7.1 für die Entwicklung von “Mango”-Apps. Süßsauer deshalb, weil nicht nur die Neuerungen beschrieben werden, sondern auch ein Auge auf noch Ausbaufähiges zur Windows Phone Entwicklung gelegt wird.

Share |

Dienstag, 27. September 2011

Windows Phone 7.5 Mango–it’s on the way

This morning, at roughly 10 a.m. Pacific time, Microsoft began rolling out the Mango update to phones around the world. Windows Phone 7.5 (aka Mango) has about 500 new features and is a major update for the Windows Phone platform.

Eric Hautala says

”I do want to emphasize that today is just the start. Our plan, as I’ll explain in a moment, is to ramp up delivery gradually—but make the update available to most existing customers within 4 weeks.

I’m sure you have lots of questions about the update process and especially when you’ll be able to install Windows Phone 7.5. Here’s our plan.”

More details see: Windows Phone 7.5 update begins

Share |

Sonntag, 7. August 2011

Windows Phone: New Silverlight toolkit announced

Good news for Windows Phone developers: it's just been announced that the Silverlight Toolkit for Windows Phone will be getting a Mango update sometime in August.

This update will giving developers just a few extra weeks to tweak their Silverlight extensions before the Marketplace starts accepting Mango apps. No word on the exact changes the new toolkit will contain, but I think Jeff Wilcox will give us some goodies in there.

Share |

Samstag, 2. Juli 2011

Windows Phone Mango 80004005 error

Currently my Mango update for Windows Phone fails with error code 80004005.

Answer from Microsoft:

“This is an error that is still being diagnosed at Microsoft.  At this time there is no workaround for it.  You should restore your phone to its NODO image and wait until there is a resolution for this problem.”

Some suggestions from Microsoft

On these crash / update issues there are two general approaches that you can try.


1. Try to apply the update using a different desktop / laptop system.

2. If a different system still doesnt' help, then remove any personal data from the device and perform a hard reset. Then try the update process again

Share |

Montag, 27. Juni 2011

MVC3: Combine JavaScript files

A nice tool on codeplex to combine and minifier several JavaScript files:

Combres - WebForm & MVC Client-side Resource Combine Library – Home

  • Open the Package Manager Console (Tools > Library Package Manager > Package Manager Console)
  • In the command window:
    • If you work with ASP.NET MVC: enter Install-Package Combres.Mvc
    • If you work with ASP.NET WebForm: enter Install-Package Combres

Register Route
This step is only necessary for ASP.NET 3.5 users. ASP.NET 4.0 users can skip to the next step. This step is necessary because there's currently no way to generate/transform/reference different code/config/assemblies for different .NET runtimes with NuGet.
  • Delete the generated file AppStart_Combres.cs
  • Remove the reference to the assembly WebActivator
  • Open global.asax code-behind file
    • Import Combres namespace, i.e. using Combres;
    • Add this to the first line of either RegisterRoutes() or Application_Start(): RouteTable.Routes.AddCombresRoute("Combres");

Modify Combres.xml
  • Open App_Data/Combres.xml (this should be auto-created when you install the Combres NuGet package)
  • Add/remove resource sets, resources etc. as per your need. See this article for more information.

Reference to Combres' resource sets in view
  • Open any view page (e.g. master page) which need to reference JS/CSS resource sets defined in Combres.xml
  • Add the followings:
<%= WebExtensions.CombresLink("siteCss") %>  
<%= WebExtensions.CombresLink("siteJs") %>
Share |