Dotnetjumper’s Weblog

Encriptando Cookies

Julio 1, 2008 · No hay comentarios

Aquí les dejo fragmento de un código que les puede ser útil a la hora de encriptar cookies en sus aplicaciones.
 

 

Imports System.Security.Cryptography.Rfc2898DeriveBytes

Imports System.Security.Cryptography

Imports System.IO

Partial Class _Default

    Inherits System.Web.UI.Page

    Public Function DecryptString(ByVal inString As String, ByVal password As String, ByVal Mysalt As String) As String

        Dim DescryText As String = “”

        Try

 

            Dim myAlg As RijndaelManaged = New RijndaelManaged()

            Dim salt As Byte() = System.Text.Encoding.ASCII.GetBytes(Mysalt)

            Dim key As Rfc2898DeriveBytes = New Rfc2898DeriveBytes(password, salt)

            myAlg.Key = key.GetBytes(myAlg.KeySize / 8 )

            myAlg.IV = key.GetBytes(myAlg.BlockSize / 8 )

 

            Dim buffer As Byte() = Convert.FromBase64String(inString)

 

            Dim memStrm As New MemoryStream()

            Dim memStrmOut As New MemoryStream(buffer)

            Dim encryptor As ICryptoTransform = myAlg.CreateDecryptor

 

            Dim encryptStream As CryptoStream = New CryptoStream(memStrmOut, encryptor, CryptoStreamMode.Read)

 

            Dim reader As New StreamReader(encryptStream)

            DescryText = reader.ReadToEnd

       

        Catch ex As Exception

            DescryText = “”

        End Try

 

        Return DescryText

    End Function

 

    Public Function EncryptString(ByVal inString As String, ByVal password As String, ByVal Mysalt As String) As String

        Dim DescryText As String = “”

        Try

 

            Dim myAlg As RijndaelManaged = New RijndaelManaged()

            Dim salt As Byte() = System.Text.Encoding.ASCII.GetBytes(Mysalt)

            Dim key As Rfc2898DeriveBytes = New Rfc2898DeriveBytes(password, salt)

            myAlg.Key = key.GetBytes(myAlg.KeySize / 8 )

            myAlg.IV = key.GetBytes(myAlg.BlockSize / 8 )

 

            Dim memStrm As New MemoryStream()

            Dim memStrmOut As New MemoryStream()

            Dim encryptor As ICryptoTransform = myAlg.CreateEncryptor

 

            Dim encryptStream As CryptoStream = New CryptoStream(memStrmOut, encryptor, CryptoStreamMode.Write)

 

            Dim writer As New StreamWriter(encryptStream)

            writer.Write(inString)

            writer.Flush()

            encryptStream.FlushFinalBlock()

            memStrmOut.Flush()

 

            DescryText = Convert.ToBase64String(memStrmOut.GetBuffer(), 0, memStrmOut.Length) 

            encryptStream.Close()

        Catch ex As Exception

            DescryText = “”

        End Try

 

        Return DescryText

    End Function

 

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a As String = EncryptString(Me.TextBox1.Text, “P@S5w0r]>”, “Proyecto”)

        Response.Cookies(“encryptcookie”).Value = a

    End Sub

 

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.TextBox2.Text = DecryptString(Request.Cookies(“encryptcookie”).Value, “P@S5w0r]>”, “Proyecto”)

    End Sub

End Class

 

→ No CommentsCategorías: Asp.net · Seguridad
Etiquetado: , ,

Unable to Start Debugging on the Web Server

Julio 1, 2008 · No hay comentarios

Allgunas posibles soluciones.

- in Users, we have ASP.NET Machine account

-Add the ASP.NET, IUSR and IWAM account to de Administrator Group
- deleted and recreated the virtual directory

- debug=”true” in web.config
- execute permissions = scripts only in virtual directory properties
- virtual directory name should be the same as the physical directory name
- ran C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
- in IIS, the correct version of ASP.NET most be selected
- HTTP Keep Alive most be checked
- IIS most be configured to use Integrated Windows Authentication
- added http://localhost to the trusted sites for local intranet
- in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files,  set full rights to “ASPNET Machine Account”
- disabled the loopback check
- verified we had Windows XP service pack 2 installed
- in IIS, verified that client side and server side debugging set to true
- verified that firewall turned off
- in IE, set security level to low.
- changed web pool to be the “Classic .NET AppPool”
- verified that in IIS properties, Document tab, I had Default.aspx

 Si poseen alguna otra solucione a problemas de debug en el servidor pueden dejarlas como comentario en este post.

→ No CommentsCategorías: Asp.net · Errores
Etiquetado: ,

FxCop: analiza el código y diseño de tu aplicación

Junio 5, 2008 · No hay comentarios

 

Microsoft a sacado una herramienta llamada FxCop la cual te permite realizar un análisis de tus assemblies en brusquedad de deficiencias en cuanto al diseño y programación, FxCop se basa en un conjunto de reglas (Rules) de las conocidas Design Guidelines, la herramienta es muy útil y muy fácil de usar, así que se las recomiendo.

 

Descarga:http://www.microsoft.com/downloads/details.aspx?FamilyID=3389f7e4-0e55-4a4d-bc74-4aeabb17997b&DisplayLang=en

 

 

 

→ No CommentsCategorías: General · Seguridad
Etiquetado: ,

Configurando ASP.NET AJAX

Abril 22, 2008 · No hay comentarios

En esta oportunidad quiero mostrar cual seria la correcta configuración del web.config en una aplicación asp.net que use ajax, esto en el caso de que se haya agregado manualmente el archivo web.config manualmente o no se haya utilizado AJAX-enabled Web Site al momento de crear nuestra aplicación.

El elemento  <configSections>  debe lucir como sigue:

<configuration>
  <configSections>
    <sectionGroup name=”system.web.extensions”
        type=”System.Web.Configuration.SystemWebExtensionsSectionGroup,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35″>
      <sectionGroup name=”scripting”
        type=”System.Web.Configuration.ScriptingSectionGroup,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35″>
          <section name=”scriptResourceHandler”
            type=”System.Web.Configuration.ScriptingScriptResourceHandlerSection,
            System.Web.Extensions, Version=1.0.61025.0,
            Culture=neutral, PublicKeyToken=31bf3856ad364e35″
            requirePermission=”false”
            allowDefinition=”MachineToApplication”/>
        <sectionGroup name=”webServices”
            type=”System.Web.Configuration.ScriptingWebServicesSectionGroup,
            System.Web.Extensions, Version=1.0.61025.0,
            Culture=neutral, PublicKeyToken=31bf3856ad364e35″>
          <section name=”jsonSerialization”
              type=”System.Web.Configuration.ScriptingJsonSerializationSection,
              System.Web.Extensions, Version=1.0.61025.0,
              Culture=neutral, PublicKeyToken=31bf3856ad364e35″
              requirePermission=”false” allowDefinition=”Everywhere” />
          <section name=”profileService”
              type=”System.Web.Configuration.ScriptingProfileServiceSection,
              System.Web.Extensions, Version=1.0.61025.0,
              Culture=neutral, PublicKeyToken=31bf3856ad364e35″
              requirePermission=”false”
              allowDefinition=”MachineToApplication” />
          <section name=”authenticationService”
              type=”System.Web.Configuration.ScriptingAuthenticationServiceSection,
              System.Web.Extensions, Version=1.0.61025.0,
              Culture=neutral, PublicKeyToken=31bf3856ad364e35″
              requirePermission=”false”
              allowDefinition=”MachineToApplication” />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
</configuration>

El elemento <controls>:registra el namespaces ASP.NET AJAX namespaces en el ensamblado System.Web.Extensions y mapea el prefijo de la etiqueta asp como alias para este namespaces.

<system.web>
  <pages>
    <controls>
      <add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
    </controls>
  </pages>
</system.web>

El elemento <assemblies>:registra el ensamblado e System.Web.Extensions

<system.web>
  <compilation>
    <assemblies>
      <add assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
    </assemblies>
  </compilation>
</system.web>

El elemento <httpHandlers>: agrega nuevos handlers para el  requests  de los scripts

<system.web>
  <httpHandlers>
    <remove verb=”*” path=”*.asmx”/>
    <add verb=”*” path=”*.asmx” validate=”false” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
    <add verb=”*” path=”*_AppService.axd” validate=”false” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
    <add verb=”GET,HEAD” path=”ScriptResource.axd” type=”System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ validate=”false”/>
  </httpHandlers>
</system.web>

El elemento <httpModules> : define los modulos HTTP usados en  ASP.NET AJAX

<system.web>
  <httpModules>
    <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
  </httpModules>
</system.web>

El elemento <system.web.extensions>: provee elementos que pueden ser descimentados para configurar como los web services son llamados desde aplicaciones ASP.NET AJAX .

<system.web.extensions>
  <scripting>
    <webServices>
    <!– Uncomment this line to customize maxJsonLength and add a
         custom converter –>
      <!–
      <jsonSerialization maxJsonLength=”500″>
        <converters>
          <add name=”ConvertMe”
             type=”Acme.SubAcme.ConvertMeTypeConverter”/>
        </converters>
      </jsonSerialization>
      –>
      <!– Uncomment this line to enable the authentication service.
           Include requireSSL=”true” if appropriate. –>
      <!–
      <authenticationService enabled=”true” requireSSL = “true|false”/>
      –>

      <!– Uncomment these lines to enable the profile service. To
           allow profile properties to be retrieved
           and modified in ASP.NET AJAX applications, you need to add
           each property name to the readAccessProperties and
           writeAccessProperties attributes. –>
      <!–
      <profileService enabled=”true”
        readAccessProperties=”propertyname1,propertyname2″
        writeAccessProperties=”propertyname1,propertyname2″ />
      –>
    </webServices>
    <!–
    <scriptResourceHandler enableCompression=”true”
        enableCaching=”true” />
    –>
  </scripting>
</system.web.extensions>

El elemento <system.webserver>: contiene los parámetros de configuración usado por  Microsoft Internet Information Server (IIS) 7.0.

 <system.webServer>
  <validation validateIntegratedModeConfiguration=”false” />
  <modules>
    <add name=”ScriptModule”
      preCondition=”integratedMode”
      type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
  </modules>
  <handlers>
    <remove name=”WebServiceHandlerFactory-ISAPI-2.0″/>
    <add name=”ScriptHandlerFactory” verb=”*” path=”*.asmx”
      preCondition=”integratedMode”
      type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
    <add name=”ScriptHandlerFactoryAppServices” verb=”*”
      path=”*_AppService.axd” preCondition=”integratedMode”
      type=”System.Web.Script.Services.ScriptHandlerFactory,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35″/>
    <add name=”ScriptResource” preCondition=”integratedMode”
      verb=”GET,HEAD” path=”ScriptResource.axd”
      type=”System.Web.Handlers.ScriptResourceHandler,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35″ />
  </handlers>
</system.webServer>

Bueno esto es todo lo que debe tener nuestro web.config, pero tan importante  como que debe tener también lo es que No debe tener nuestro web.config y en este caso me refiero al elemento <xhtmlConformance/> , cuando este elemento contiene mode=”Legacy” puede producir comportamientos extraños tanto para nuestro ajax como para nuestro código javascript.

El elemento <xhtmlConformance mode=”Legacy”/> es agregado automáticamente cuando migramos un proyecto de VS 2003 a VS 2005.

Les dejo los enlaces con los artículos completos acerca de la configuración del web.config en aplicaciones Asp.Net Ajax.

http://www.asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx

http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx

 

→ No CommentsCategorías: Ajax · Asp.net · General
Etiquetado: , ,

IT Architecture

Abril 21, 2008 · No hay comentarios

The Architecture Journal es una publicación realizada por MSDN dedicada a la arquitectura de IT incluyendo software, servicios, aplicaciones móviles, infraestructura y mucho más. Hasta ahora van por la publicación numero 14, así que les dejo el enlace para que puedan acceder a esta y todas las publicaciones ya entregadas.

http://msdn2.microsoft.com/en-us/arcjournal/default.aspx

 

→ No CommentsCategorías: General · arquitectura
Etiquetado:

Lenguajes dinámicos en .Net

Abril 21, 2008 · No hay comentarios

En vista de las nuevas características de ASP.Net para soportar implementación de lenguajes dinámicos como phyton y ruby en las  nuevas versiones de C# 3.0 y VB 9.0. Silverlight  he decidido dejarle algunos enlaces que le serán de mucha utilidad si deciden adentrarse en estas nuevas características de ASP.Net. (la mayoria de los enlaces pertenecen a Codeplex)

  1.  Descarga de IronPhyton versión 1.1 (estable) y de IronPhyton versión 2.0 (alpha)
  2. Notas de liberación de IronPhyton versión 1.1 (estable) y de IronPhyton versión 2.0 (alpha)

→ No CommentsCategorías: Asp.net · General · Lenguajes Dinamicos
Etiquetado: ,

Nuevas Certificaciones Microsoft para Desarrolladores

Abril 8, 2008 · No hay comentarios

Para aquellos que estén interesados en saber un poco de las nuevas certificaciones de Microsoft basadas en el Framework 3.5 dejo un enlace al blog de Howard Dierking que describe algunas de sus características.

http://blogs.msdn.com/howard_dierking/archive/2007/03/25/orcas-certifications-follow-up-implications-for-mcpd.aspx?

Certification Exams
MCTS: WPF TS: WPF + 70-536
MCTS: WCF TS: WCF + 70-536
MCTS: WF TS: WF + 70-536
MCTS: ASP.NET 3.5 TS: ASP.NET 3.5 + 70-536
MCTS: ADO.NET 3.5 TS: ADO.NET 3.5 + 70-536

→ No CommentsCategorías: Certificaciones
Etiquetado: ,

Errores comunes en Asp.Net

Abril 7, 2008 · No hay comentarios

A continuación les dejo un enlace a la pagina del chicodotnet.com en la cual podrán encontrar un articulo sobre errores comunes en asp.net.

http://www.google.co.ve/search?hl=es&q=los+10+errores+de+seguridad+mas+comunes&meta=

→ No CommentsCategorías: Seguridad
Etiquetado: ,

Hola Geek’s y .Net Developers!

Abril 4, 2008 · No hay comentarios

Hola la idea de este blog es ir posteando link’s a otros blogs que suelo visitar con frecuencia y cuyo contenido me parece de gran interés, para los geek y sobre todo para desarrolladores .Net. De manera que les haré saber de lo mejor que consiga en mi interacción con la bloggosfera. Saludos.

→ No CommentsCategorías: General
Etiquetado:

ASP.NET 2.0 Security Practices

Abril 4, 2008 · No hay comentarios

→ No CommentsCategorías: Seguridad
Etiquetado: , ,