Auto Bundling and Minifying the .css .js files

image

image

The new bundling/minification feature now allows you to instead bundle and minify all of the .css files in the Styles folder – simply by sending a URL request to the folder (in this case “styles”) with an appended “/css” path after it.

This will cause ASP.NET to scan the directory, bundle and minify the .css files within it, and send back a single HTTP response with all of the CSS content to the browser.

A 90 seconds Video.

Using the ASP.NET Membership Provider and Authentication Service from Windows Phone 7

image

Those of you who have been building ASP.NET applications for a while now are no doubt familiar with the provider model, which includes provider abstractions for membership (authentication), roles (authorization), profiles (user data), and session state. These providers make it incredibly easy to provide a secure framework for your application. In fact, with an ASP.NET application template right out of the box, you can have a fully functioning authenticated, secure website in minutes.

What a lot of people have less familiarity with is the notion of provider services. You can actually create a WCF service head that sits on top of the ASP.NET membership system. This allows client applications (WP7) to authenticate against your ASP.NET website using exactly the same authentication scheme that your users use. This means that a user who has access to your website should also be able to have access to the client application seamlessly.

If you already have an ASP.NET application that is using the membership provider, role provider, and profile provider you can quickly, easily, and securely expose services to a mobile (WP7) client that allow that client to have secured, remote access to services exposed by that site. In short, any user of your existing web application can use their existing credentials to log in from their WP7 device and access any services you decide to make available.

ASP.NET provider services, coupled with WP7 and the fact that Silverlight has access to WCF client proxy generation, means you can very easily prep your site for a rich WP7 experience.

To read more…

ASP.NET 4 SEO Improvements

Page.MetaKeywords and Page.MetaDescription properties

One simple recommendation to improve the search relevancy of pages is to make sure you always output relevant “keywords” and “description” <meta> tags within the <head> section of your HTML.  For example:

image

One of the nice improvements with ASP.NET 4 Web Forms is the addition of two new properties to the Page class: MetaKeywords and MetaDescription that make programmatically setting these values within your code-behind classes much easier and cleaner. 

Response.RedirectPermanent() Method

It is pretty common within web applications to move pages and other content around over time, which can lead to an accumulation of stale links in search engines.

In ASP.NET, developers have often handled requests to old URLs by using the Response.Redirect() method to programmatically forward a request to the new URL.  However, what many developers don’t realize is that the Response.Redirect() method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs.  Search engines typically will not follow across multiple redirection hops – which means using a temporary redirect can negatively impact your page ranking.  You can use the SEO Toolkit to identify places within a site where you might have this issue.

ASP.NET 4 introduces a new Response.RedirectPermanent(string url) helper method that can be used to perform a redirect using an HTTP 301 (moved permanently) response.  This will cause search engines and other user agents that recognize permanent redirects to store and use the new URL that is associated with the content.  This will enable your content to be indexed and your search engine page ranking to improve. ASP.NET 4 also introduces new Response.RedirectToRoute(string routeName) and Response.RedirectToRoutePermanent(string routeName) helper methods that can be used to redirect users using either a temporary or permanent redirect using the URL routing engine.

For more goto –> ASP.NET 4 SEO Improvements (VS 2010 and .NET 4.0 Series) – ScottGu’s Blog

Eliminate duplication in CSS with .less – a .NET HTTP handler

 

One of the frustrating aspects of working with CSS (one of many, actually) is the amount of duplication in a .css file. .less help to keep your CSS files DRY using 4 constructs:

  • Variables
  • Mixins
  • Operations
  • Nested Rules

image

An HTTP handler is configured to respond to requests for the .less files.

<httpHandlers>
    <add type="dotless.Core.LessCssHttpHandler, dotless.Core" validate="false" path="*.LESS" verb="*"/>
</httpHandlers>

When a request arrives for a .less file it is the handler’s job to parse the .less file and transform it into standard CSS rule sets.

What’s new in ASP.NET 4 – Short Videos

 

#1 | ASP.NET 4 "Quick Hit" – Chart Control 2 minutes, 42 seconds

#2 | ASP.NET 4 "Quick Hit" – Dynamic Metadata 5 minutes, 37 seconds

#3 | ASP.NET 4 "Quick Hit" – Permanent Redirect 5 minutes, 35 seconds

#4 | ASP.NET 4 "Quick Hit" – Imperative WebForms Routing 12 minutes, 39 seconds

#5 | ASP.NET 4 "Quick Hit" – Declarative WebForms Routing 14 minutes, 16 seconds

#6 | ASP.NET 4 "Quick Hit" – Outbound WebForms Routing 6 minutes, 18 seconds

#7 | ASP.NET 4 "Quick Hit" – Auto Start 11 minutes, 38 seconds

#8 | ASP.NET 4 "Quick Hit" – Clean Web.Config Files 2 minutes, 41 seconds

#9 | ASP.NET 4 "Quick Hit" – Predictable Client IDs 10 minutes, 47 seconds

#10 | ASP.NET 4 "Quick Hit" – Selective View State 6 minutes, 40 seconds

#11 | ASP.NET 4 "Quick Hit" – The HtmlEncoder Utility Method 5 minutes, 8 seconds

Via ASPNET 4 : The Official Microsoft ASP.NET Site

MVC or Web Forms? A Dying Question

 

Everyone who talks about ASP.NET MVC gets asked the question:

    Should I use MVC or Web Forms?

There’s been quite a bit of debate on this topic, but in a couple years I don’t think it will matter.

twin cars

and the stories continues here MVC or Web Forms? A Dying Question until …

spectrum

The question in the next decade won’t be: “MVC or Web Forms?”.

The question will be: “MVC or SharePoint?

But nobody will ask the question, because the answer is easier to figure out.

:>

AsynFileUpload – from AJAX Control Toolkit

 image

AsynFileUpload Control

The second new control included in the newest release of the AJAX Control Toolkit is the AsyncFileUpload control. You can use this control to display a fancier interface for uploading files. The AsyncFileUpload control:

  • Enables you to perform file uploads without doing a postback
  • Displays a throbber images while an image is being uploaded
  • Raises both server and client events when a file upload completes or when there is an error.
  • Works inside and outside of an UpdatePanel

Admit it! The standard file upload widget that you get with HTML is boring. You can’t display a picture while a file is uploading. And, it forces you to do a postback which is bad in this new Ajax world.

<asp:UpdatePanel ID="up1" runat="server">  
  <ContentTemplate>  
    <h1>Add File</h1>  
    File: <br />  
    <cc1:AsyncFileUpload ID="AsyncFileUpload1" onuploadedcomplete="AsyncFileUpload1_UploadedComplete" runat="server" />  
    <br /><br />  
    Description:<br />  
    <asp:TextBox ID="txtDescription" runat="server" />  
    <br /><br />  
    <asp:Button ID="btnSubmit" Text="Add File" runat="server" />  
    </ContentTemplate>  
</asp:UpdatePanel>  
public partial class TestAsnycFileUpload : System.Web.UI.Page  
{  
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)  
    {  
        System.Threading.Thread.Sleep(5000);  
        string savePath = MapPath("~/Uploads/") + Path.GetFileName(e.filename);  
        AsyncFileUpload1.SaveAs(savePath);  
    }  
}
  

Via New AJAX Control Toolkit Release

A better solution to find ASP.NET ClientIDs with jQuery

 

A small routine that returns us a jQuery object based on only the id:

function $$(id, context) {
    var el = $(&quot;#&quot; + id, context);
    if (el.length &lt; 1)
        el = $(&quot;[id$=_&quot; + id + &quot;]&quot;, context);
    return el;
}

So in simple usage to select my ctl00_MainContent_txtSymbol value both of the following work:

alert( $$(&quot;txtSymbol&quot;).attr(&quot;id&quot;) );

Or if I want to be specific about the container:

alert( $$(&quot;txtSymbol&quot;,$(&quot;#wrapper&quot;)).attr(&quot;id&quot;) );

Via A generic way to find ASP.NET ClientIDs with jQuery – Rick Strahl’s Web Log