- Microsoft ASP.NET MVC hits Gold + free eBook!
-
Posted by oVan on Friday, March 20, 2009 | PermaLink | 1 comments
After what seemed like an never ending rally of preview, beta, CTP and RC versions, Microsoft has finally released the RTW (Ready To Web) version of ASP.NET MVC.
In plain English, that means the official version 1.0 of the MVC framework for ASP.NET is now a fact. You’ll find a truckload of sample code, videos and tutorials at the ASP.NET MVC Center. You’ll also find a gallery there, featuring some nice design templates (skins) to get you started on your MVC project.
While we’re waiting on the Gu (Scott Guthrie) to release his long awaited blog post on this release, here’s a must read post of him: Free ASP.NET MVC eBook Tutorial. Additionally, here are some videos to get your started:

- Learn MVC: Understanding Models, Views and Controllers
- Learn MVC: ASP.NET MVC Controller Overview
- Learn MVC: Creating a Movie Database Application with ASP.NET MVC
You can find more videos here:
» More “How Do I” Videos
» More MVC Videos
- Easily timing your website speed
-
Posted by oVan on Friday, January 30, 2009 | PermaLink | 0 comments
There are many ways to time the speed of your website, using php, asp, asp.net or simple javascript. They all have the disadvantage that you need to include your scripts on every page you want to time, and once your site is published live on the webserver, you don’t want every visitor to see these timing results.
Here’s a simple and elegant solution, and it’s free! The Numion Stopwatch website has a simple textbox to enter the url you want to time.
Note: once your site or page is loaded and timed, you can push the result button to test again. A separate button would be much clearer.
Link: http://www.numion.com/Stopwatch/Labels: asp.net, performance, php, web development, webdev
- Microsoft releases .NET Framework 3.5 Service Pack 1
-
Posted by oVan on Wednesday, January 07, 2009 | PermaLink | 0 comments
Microsoft .NET Framework 3.5 Service Pack 1 is a cumulative update with service updates to the .NET 2.0 and 3.0 subcomponents, and contains many new features for the .NET Framework 2.0, 3.0, 3.5.
Quick overview of what’s new:
- ASP.NET Dynamic Data is now included, providing rich scaffolding framework for rapid data driven development without writing code. See What's new in ASP.NET and Web Development for more info.
- Addition to ASP.NET AJAX for managing browser history (back button support).
- Core improvements to the CLR (Common Language Runtime)
- Performance improvements to WPF (Windows Presentation Foundation)
- Additional functionality in WPF: better support for line of business apps, native splash screen support, DirectX pixel shader support, and a new WebBrowser control.
- ClickOnce application publishers can opt out of signing and hashing.
- Entity Framework (an evolution of the well known ADO.NET) is included and has new features like support for SQL Server 2008. See Getting Started with the Entity Framework for more info.
- LINQ to SQL and SqlClient (.NET Framework Data Profider for SQL) now support the date and file stream capabilities in SQL Server 2008.
- ADO.NET Data Services Framework is included, and enables data to be exposed as flexible REST (Representational State Transfer) data services.
- Windows Communication Foundation (WCF) has improvements to the DataContract Serializer.
Downloads & links:
After installation, immediately install the update KB959209 to address a set of known application compatibility issues!
Labels: .NET, asp.net, download, LINQ, Microsoft, SP1, SQL, Visual Studio 2008
- Microsoft Web Platform Installer
-
Posted by oVan on Wednesday, October 08, 2008 | PermaLink | 0 comments
Microsoft has released a new tool aimed at web developers: Microsoft Web Platform Installer. Although it’s still a beta, it’s already a one-stop shop to install all necessary tools, service packs and extensions, including IIS, ASP.NET, SQL Server 2008, Visual Web Developer 2008, all of the current IIS Extensions and more!
Once installed, this tool automatically discovers new additions and updates to the platform, keeping you up to date.Additionally, Microsoft has launched a new website for web professionals (designers and developers): microsoft.com/web
Go to: Microsoft Web Platform Installer site, or download wpilauncher.exe immediately.
Labels: .NET, 2008, asp.net, C#, developer, download, Express, install, installation, installer, Microsoft, Vista, Visual Studio 2005, Visual Studion 2008, vs2005, vs2008, web development, webdev, Windows, Windows Vista
- How-To: Build Language dropdown with ASP.NET MVC and LINQ
-
Posted by oVan on Wednesday, May 28, 2008 | PermaLink | 0 comments
Here's a quick way to build a language dropdown box with ASP.NET MVC Preview 3, without using a database table. In total we need only 3 lines of code.
1. Controller:
In our controller, we add the following code to the controller action:
List<System.Globalization.CultureInfo> Locales =
System.Globalization.CultureInfo.GetCultures(
System.Globalization.CultureTypes.NeutralCultures).ToList();ViewData["Locales"] = new SelectList(
Locales
.OrderBy(lc => lc.Name.Length)
.ThenBy(lc => lc.DisplayName),
"Name",
"DisplayName");First we create a list of CultureInfo and store it in a variable Locales. For this example I've used NeutralCultures to limit the entries to the most used languages, otherwise you'll get a very long list.
Next we create a ViewData object and fill it using SelectList, passing along our Locales variable.
Note: I've sorted Locales twice, first with OrderBy and then with ThenBy. As parameter we throw in a Lambda expression to transform our Locales and get the member we want. The reason I sort on Name.Length first is that the Invariant CultureInfo has an empty Name and thus it will be sorted to the top of the list.
After that we simply render our View (in this case passing along a Contact record from the database.
2. View:
The code in our view is even simpler. With the help of Extensions and MVC HtmlHelper objects we have our dropdown box in no time:
The only line of code to render the fully functional html select dropdown box is this:
<%=Html.DropDownList("Locales") %>
Here is the final result:
A quick look at the produced code shows us the clean XHTML underneath:
<select name="Locales" id="Locales">
<option value="">Invariant Language (Invariant Country)</option>
<option value="af">Afrikaans</option>
<option value="sq">Albanian</option>
<option value="ar">Arabic</option>
<option value="hy">Armenian</option>
<option value="az">Azeri</option>
<option value="eu">Basque</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
...Ps: in the screenshots above I've used a test version of TheSansMono OpenType by Luc(as) de Groot. This font will be published soon on the LucasFonts website, together with TheSansCondensed OpenType. Typographer Luc(as) de Groot is also known for the Calibri and Consolas fonts in Windows Vista and Microsoft Office 2007.
- FIX: GoogleBot produces "Cannot use a leading .. to exit above the top directory" in ASP.NET
-
Posted by oVan on Sunday, April 06, 2008 | PermaLink | 0 comments
I found numerous "Cannot use a leading .. to exit above the top directory" errors in my Elmah-logs lately, all of them generated by the ASP.NET engine after a visit from GoogleBot. It is caused by using URL rewriting in your aspx-pages in order to have more readable URL's and better search engine rankings.
Funnily, this only started after I submitted dynamically generated sitemaps to the Google Webmaster Tools for my clients websites. Instead of improved ranking and indexing, however it resulted in exclusion of all failing URL's.
For more background information about this error, which is generated only for certain user agents including GoogleBot and Yahoo! Slurp, you can do a simple Google search. There are a few solutions to fix this, but most involve using a custom base page class or creating different .browser files for each problematic user-agent in the App_Browser directory. Having done custom browser.ini solutions with Browserhawk years ago, I did not feel like starting all over again with googlebot.browser, yahooslurp.browser etc.
By far the easiest solution is a simple change in your web.config:
Find the <authentication> section, then change the <forms> line by adding:cookieless="UseCookies"
Voila, the problem is fixed. Note that this disables cookieless functionality for forms, so if you really need that you should use a different solution.
Labels: .NET, asp.net, browser, bug, Google, Microsoft, problem, Visual Studio 2005, Visual Studion 2008, vs2005, vs2008
- How-to: Viewing current Route in ASP.NET MVC
-
Posted by oVan on Friday, December 21, 2007 | PermaLink | 2 comments
For those who are playing with the ASP.NET MVC CTP bits, here's an easy way to check the routing info that was used to arrive at your View. You need to enter this into your Site.Master shared view, put it just below the menu-div.
<div class="debug">
<dl>
<dt>Current routing url:</dt>
<dd><%= ViewContext.RouteData.Route.Url.ToString()%>
</dd>
<dt> Current routing values:</dt>
<dd>
<ol><%= ViewContext.RouteData.Values.ToFormattedList("<li>{0}</li>") %></ol>
</dd>
</dl>
</div>
- Visual Studio 2008 and .NET 3.5 are here!
-
Posted by oVan on Monday, November 19, 2007 | PermaLink | 0 comments
The Wait for Visual Studio 2008 is Over!
On Monday, Nov. 19, Microsoft announced that Visual Studio 2008 and the .NET Framework 3.5 were released to manufacturing (RTM). With more than 250 new features,Visual Studio 2008 includes significant enhancements in every edition, including Visual Studio Express and Visual Studio Team System. Developers of all levels – from hobbyists to enterprise development teams – now have a consistent, secure and reliable solution for developing applications for the latest platforms: the Web, Windows Vista, Windows Server 2008, the 2007 Office system, and beyond.
- MSDN Subscribers: Get Visual Studio 2008 Now
- Download Trial Editions of Visual Studio 2008
- Download Visual Studio 2008 Express Editions
- Download the .NET Framework 3.5
Labels: .NET, asp.net, C#, free, Microsoft, MSDN, Visual Studio Orcas, web develoment, Windows
- ResolveUrl with no Page or Control in sight
-
Posted by oVan on Monday, October 29, 2007 | PermaLink | 1 commentsWhile working (sweating) on a client's website, I needed a reliable ResolveUrl method without making use of the Page or Control classes. A few quick Googles resulted in some working functions, although not all of them resulted in the same output as the real ResolveUrl.
Some solutions use the VirtualPathUtility for that, however it throws an HttpException when the url to be resolved contains a query string. The most elegant, and from what I can tell also the most correct function came from a comment by Richard Deeming on Rick Strahl's blog:
public static string ResolveUrl(string originalUrl)
{
if (!string.IsNullOrEmpty(originalUrl) && '~' == originalUrl[0])
{
int index = originalUrl.IndexOf('?');
string queryString = (-1 == index) ? null : originalUrl.Substring(index);
if (-1 != index) originalUrl = originalUrl.Substring(0, index);
originalUrl = VirtualPathUtility.ToAbsolute(originalUrl) + queryString;
}
return originalUrl;
}
To resolve the full URL, he uses the Uri and UriBuilder classes:
public static string ResolveServerUrl(string serverUrl, bool forceHttps)
{
Uri result = HttpContext.Current.Request.Url;
if (!string.IsNullOrEmpty(serverUrl))
{
serverUrl = ResolveUrl(serverUrl);
result = new Uri(result, serverUrl);
}
if (forceHttps && !string.Equals(result, Uri.UriSchemeHttps))
{
UriBuilder builder = new UriBuilder(result);
builder.Scheme = Uri.UriSchemeHttps;
builder.Port = 443;
result = builder.Uri;
}
return result.ToString();
}
This code works beautifully!
Source: read the original article and many interesting comments: ResolveUrl-without-page.
- Adding a Content Role in MWPSK
-
Posted by oVan on Thursday, March 22, 2007 | PermaLink | 0 commentsHere's an easy solution to add a Content Editor role in the MyWebPagesStarterKit without defining a new role (which would take a lot of work):
Currently the authenticated user that is not part of the administrator role can do nothing more than an anonymous (unauthenticated user) user on the website.
So let's assume that those non-admin authenticated users are just content editors. We want them to be able to add/change the content of the defined section controls, without the ability to delete sections or to change the sitemap structure.
Here are the two easy steps to accomplish this:
1) Change the following in ~/Default.aspx.cs:
foreach (ISection section in _page.Sections)
{
SectionControlBaseClass ctl = (SectionControlBaseClass)LoadControl(section.UserControl);
if (User.Identity.IsAuthenticated && User.IsInRole(RoleNames.Administrators.ToString()))
Into:
foreach (ISection section in _page.Sections)
{
SectionControlBaseClass ctl = (SectionControlBaseClass)LoadControl(section.UserControl);
if ((User.Identity.IsAuthenticated))
The above change will enable the admin functions for sections on each page, whithout enabling the administration menu for administrators.
2) Change the following line in ~/SectionControls/SectionAdmin.ascx:<asp:Button runat="server" ID="btnDeleteSection" OnClick="btnDeleteSection_Click" Text="<%$ Resources:stringsRes, glb__DeleteSection%>" CausesValidation="false" UseSubmitBehavior="false" />
Into:
<% if (Context.User.IsInRole(MyWebPagesStarterKit.RoleNames.Administrators.ToString())) {%><asp:Button runat="server" ID="btnDeleteSection" OnClick="btnDeleteSection_Click" Text="<%$ Resources:stringsRes, glb__DeleteSection%>" CausesValidation="false" UseSubmitBehavior="false" /><% } %>
The above change will remove the ability to delete section controls.
The result will enable authenticated users to update the content of the website, withouth the ability to destroy it :-)
Hope this helps!Labels: Administrator, asp.net, CodePlex, content, editor, fix, Microsoft, MWPSK, MyWebPagesStarterKit, patch, role, starter kit
