Running ASP.NET 3.5 on IIS

21. September 2009

Where is ASP.NET 3.5 on IIS ?


Most people on installing .NET 3.5 on the server "expect" an entry for v3.5 under the ASP.NET version Tab in IIS manager. And not finding that entry start panicking. If you have been one of those read on. The more tech savvy folks try to run aspnet_regiis -i from the v3.5 framework folder... but even that is missing.



That brings us to the questions:

What exactly is ASP.NET 3.5 ?


Take a look at the v3.5 framework folder you will not find most of the files needed for ASP.NET to run like aspnet_isapi.dll / aspnet_filter.dll / aspnet_regiis.exe / aspnet_regsql.exe...

The reason being .NET 3.5 is not a stand alone framework like v2.0 or v1.1 . It is just an extension of the 2.0 framework. The extension provides developers with new language features like Anonymous Types, Extension Methods, Lambda Expressions and of course LINQ .... and AJAX is now integrated ... also you have a few new ASP.NET controls <asp:ListView>, <asp:LinqDataSource>, <asp:DataPager>

Will I get ASP.NET version 3.5 under the ASP.NET tab in IIS 6.0 ?


No. Because as far as IIS is concerned nothing has changed. The aspnet_isapi.dll from the version 2.0 folder will still handle the requests and there is no new ISAPI dll specific to version 3.5. So you don't have to change any Script Mappings in IIS ...just leave the web application pointing to v2.0 under the ASP.NET Tab. And this brings us to the next question

What exactly is the extension ?


For that if you have Visual Studio 2008 go ahead and create a Website targeting the .NET 3.5 framework. Then go to the Property Pages of the Website and select References. You will find an entry like this:



And those four assembly references provide the new features of v3.5.  Here is a 10,000 ft view of the functionality implemented in these assemblies

System.Core - Provides namespaces like System.Linq, System.IO
System.Data.DataSetExtensions - LINQ to DataSet
System.Web.Extensions - AJAX
System.Xml.Linq - New XML API.. supports LINQ to XML

Do I have to configure anything manually ?


No. When you install the .NET 3.5 redistributable on the server it installs these assemblies in the GAC. And any website that refers to these assemblies can fetch them from the GAC so you do not have to configure anything manually. All you need to do is publish the content to a web application that is marked with ASP.NET v2.0

And now you should be thinking

The new language features should require a new compiler. How exactly is the new compiler used ?


The answer is your web.config file. When you create an ASP.NET 3.5 website in Visual Studio 2008 an entry is made in the web.config something like

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
              type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="WarnAsError" value="false"/>
    </compiler>

The new features do require a new compiler to be used and the web.config tells .NET that the v3.5 compiler has to be used.

What about IIS 7.0 ?


IIS 7.0 is no different.




Mario Alberto Arce, from http://blogs.msdn.com/vijaysk/archive/2008/03/20/running-asp-net-3-5-on-iis.aspx

Mario Alberto Arce @ 10:15

Currently rated 1.9 by 14 people

  • Currently 1.92857/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

.Net, .Net, .Net, .Net, .Net, .Net, .Net, .Net, Tips & Examples, Tips & Examples, Tips & Examples, Tips & Examples, Tips & Examples, Tips & Examples, Tips & Examples, Tips & Examples , , , , , , , , , , , , , , , , , , , , , , ,

Tips para evitar Spam Filters

22. May 2009
Primero que todo la forma para evitar Spam Filers básicamente no existe, es lógico, los 'spammers' ya hubiesen adoptado esas prácticas. Pero sí existen consejos y buenas prácticas para evitar que los correos que los sistemas envían automáticamente logren obtener la menos cantidad de 'hits' de spam.

Enviar correos de solo texto es feo y anticuado, pero para poder enviar correos atractivos a clientes o usuarios es necesario usar HTML, desafortunadamente esto aumenta la posibilidad de ser catalogado como spam. Spam Filters como SpamAssassin trata los correos electrónicos con HTML como potencialmente peligrosos, por lo que se debe usar con cuidado.

Aquí se enumeran algunas de las recomendaciones para los correos electrónicos que se envían automáticamente a través de sistemas:

  • crear dos tipos de Bodys, uno Html y otro PlainText o solo texto
Por ejemplo en C# / ASP.NET 2.0 usando la clase System.Net.Mail se puede pueden crear AlternateViews, en lugar de usar directamente la propiedad .Body, es importante además que el texto de ambas vistas sea el mismo:

MailMessage mailMessage = new MailMessage();
...
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(bodyText, null, "text/plain");
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(bodyHtml, null, "text/html");

mailMessage.AlternateViews.Add(plainView);
mailMessage.AlternateViews.Add(htmlView);

  • indicar siempre un Encoding correcto para el mensaje que se está enviando, por ejemplo:
mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
  • indicar un Message-ID válido en el header del correo
mailMessage.Headers.Add("Message-ID", messageId);

la forma correcta del Message-ID es como un FQDN (Fully Qualified Domain Name), este es un nombre que incluye el nombre de la computadora y el nombre de dominio asociado a ese equipo (ver http://es.wikipedia.org/wiki/FQDN)

el mismo siempre deber ir dentro de brackets, por ejemplo:

<282d02960905221208o57db2aedwfe91b2793003b447@mail.gmail.com>

antes del arroba normalmente se pone un identificador único del mensaje. Los Message-ID muy cortos también son penalizados
  • validar el código HTML, es importante validar que el código HTML no contenga error, tags mal cerrados o mal escritos, además usar solamente tags estándar de HTML
  • se puede utilizar CSS para dar formato a los correos, pero de la misma manera que el HTML se debe validar que no tenga errores, se deben usar estilos estándar, para fuentes de letras utilizar las fuentes estándar, usar un tamaño estándar de letra, no usar letras pequeñas por que son calificadas como practicas spam
  • MAYÚSCULAS No, evitar el uso de mayúsculas  !!!
  • configurar el correo correctamente, indicar correctamente el From Address y el From Name del correo
  • utilizar una cuenta y servidor de correo confiables y sobre todo bien configurado
  • se pueden utilizar imágenes, un buen número es entre 1-3 imágenes. Evitar los correos que solo contengan imágenes, debe incluirse una buena cantidad de texto
  • evitar cosas como: letras itálicas y con tamaño de letra o muy grande o muy pequeño, usar colores no estándares, incluir Forms en el correo
  • evitar Anexos o Attachments, aumentan inclusive la posibilidad de distribuir virus
  • evitar incluir muchos destinatarios como BCC

Estos son algunos de muchos consejos para tratar de evitar los Spam Filters, es recomendable hacer muchas pruebas antes de liberar sistemas que envíen correos electrónicos de forma automática, se deben hacer constantemente mejoras para lograr la menor cantidad de hits por parte de los Spam Filters.

Tips

http://www.emaildeliveryjedi.com/avoid-spam-filters.php
http://www.businessstrata.com/Win/Email-Marketing/How-to-Avoid-Spam-Filters/
http://www.andreas-kraus.net/blog/tips-for-avoiding-spam-filters-with-systemnetmail/
http://www.masternewmedia.org/news/2008/05/24/spam_checking_tools_and_tips.htm
http://www.marketingforsuccess.com/wordstoavoid.html

Recursos

http://www.lyris.com/resources/email%2Dmarketing/
http://www.mailingcheck.com/download-spam-checker/

Sobre SpamAssassin

http://spamassassin.apache.org/tests_3_2_x.html
http://wiki.apache.org/spamassassin/CategoryRule
Mario Alberto Arce @ 08:28

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

.Net, Tips & Examples , ,

Library Dependency and SOA Modular Development

26. February 2009

There always has been been promises to solve tech problems since ever; although, sometimes a solution creates another problem, first we had monolithic applications where all code has to be written by the same team; from I/O access to Presentation; then we had libraries to concentrate common pieces of code for a particular task, but these libraries created to be reuse had interdependencies with other libraries of code, then to solve these interdependencies we create versioned libraries and ship them in a single file, but as we had versioning we start to have problems with libraries having dependencies for a particular version and any new version might break the code; thus our code is still tightly coupled; even though, we have tried all tricks in the book (and some that aren’t in the book) to decouple our modules.


One common approach is to use patterns such factories to decouple the modules and leave the factory to decide (based on configuration) which “module” to deliver, and yet still once the object has been delivered it cannot be retaken or change into some new version; despite all these efforts, one fundamental problem remains: “how to decouple our modules and make them resilient to change in other modules”. Since 1999 there has been efforts from a group to define a standard for a framework capable of this decoupling, it first started as a solution for device communication where its applicability is obvious (i.e. in a Smart House where appliances come a goes any time) where the modules should be self aware of each other and auto-configurable.
Nowadays this framework is making its way into the enterprise application world to allow a SOA environment to exists in a single JVM or distributed JVMs, making modules reusable, secure, distributed, resilient, environment aware, self configurable, versioned and more; it varies from WS SOA in not requiring a transport layer removing this overhead and making services resilient. This framework its defined by OSGi Alliance and they provide the detailed specs for the framework but several implementations can be found both in commercial and open source versions, some examples are:

http://www.knopflerfish.org/
http://www.eclipse.org/equinox/
http://felix.apache.org/

A promise of a SOA environment without the overhead of the transport layer and a build in ability to react to failures and code changes is a great improvement it definitely adds a great number of advantages for (at last) modular development. We definitely should keep an eye in the releases of implementations of RFCs from this group.

Allan Cascante @ 05:37

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tips & Examples, Comentarios , ,

Google Calendar in a ASP.Net Page

17. December 2008

It has been a while since I discovered Google Calendars; although, lately it have drove my attention the extensive coverage of the API available for this application, so I though give it a try.

I found that Google Calendar expose the calendars as XML, ICAL and HTML; browsing around I found that ICAL is actually an Internet Standard defined in the RFC2445; so at first I tough of parsing the ICAL entries myself, later on I found a .Net 2.0 libray for ICal named DDay.iCal so I tough of integrating both into a simple ASP.Net application to show a calendar with the events on the given dates.

The integration between iCal and Google Calendar is very straight forward, first I went to Google Calendar and got the url for the calendar I want to navigate to, by selecting calendar's setting from the menu as shown bellow.

 


Then I select the iCal button and save the url shown in the pop-up for later (as shown bellow):





Then is just matter of creating a web project you can use Visual Studio 2005 as I did; then I added the references to DDay.iCal.dll and antlr.runtime.dll; in the Default.aspx page I create some components:

- A TextBox in case we need to load another Google Calendar.
- A Button to reload the Calendar from the TextBox.
- A Calendar to display the dates having Events.
- A Repeater to show all events for the selected date of the calendar.

The most important section of the aspx page, is the item template section of the repeater, this will bind the occurrences of the events in the calendar to display the Event details:

<ItemTemplate>
<div class="item">
<div class="time"><%# GetTime(Container.DataItem)%></div>
<span class="bold"><%# DataBinder.Eval(Container.DataItem, "Component.Summary") %></span>
</div>
</ItemTemplate>

The GetTime method will obtain the Time for the Event Occurrence, and the Eval will get the Summary for the Event.

protected string GetTime(object obj)
{
Occurrence occurrence = obj as Occurrence;
if (occurrence != null)
{
Event currentEvent = occurrence.Component as Event;
if (currentEvent != null)
{
if (currentEvent.IsAllDay)
return "All Day";
else return currentEvent.Start.Local.ToString("h:mm tt");
}
}
return string.Empty;
}

Since the iCal library follows the iCal standard, we only need to call this method

calendar = iCalendar.LoadFromUri(new Uri(GoogleCalendarURLTextBox.Text));

Where the Text in the TextBox points to a valid ICAL stream; therefore, we set the TextBox with the url we copied from the pop-up from Google Calendar. Now calendar has all the calendar entries from Google Calendar.

To mark dates in the Calendar where the Google Calendar has valide events occurences we implement some code for the Calendar DayRender event to check if the current rendered date has event occurrences and change the background color of the cell:

protected void GoogleCalendar_DayRender(object sender, DayRenderEventArgs e)
{
//When a date is render check if it has a event and mark the day in the calendar
if (calendar != null)
{
if (calendar.GetOccurrences(e.Day.Date).Count > 0)
{
//Paint the day with a red color
e.Cell.Attributes.Add("style", "{background-color:yellow;");
}
}
}

The we need some code to bind the Event Occurrences for the given date for the repeater to show the details, to do this we add a method to be called by the Selection Changed event of the calendar as follows:

protected void GoogleCalendar_SelectionChanged(object sender, EventArgs e)
{
//When selecting a date load the event in the Repeater
DailyEventsRepeater.DataSource = calendar.GetOccurrences(GoogleCalendar.SelectedDate);
DailyEventsRepeater.DataBind();
}

The previous code is practically all that we need to actually display the events in our google calendar and the details when a date is selected. Later some code to optimize the page can be included.

This is the finall application:


 
  Allan Cascante @ 05:23

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tips & Examples, .Net , , ,