9.11.09

Convertendo byte[] para string e string para byte[]

Dias desses estava estudando algumas soluções as quais tinham como premissa a transformação de strings em um array de bytes e vice-versa.

Bom, pesquisei daqui e de lá e encontrei vários artigos aonde mostravam como fazer essa conversão. Todos usavam o objeto System.Text.ASCIIEncoding, mas este link é de um artigo no Erwin's Blog aonde ele mostra como fazer essa conversão quando não se sabe qual enconding usar (But what if you don’t know the encoding type?).

Abixo transcrevo o código que resolve esse nosso problema.


public static byte[] ConvertStringToBytes(string input)
{
System.IO.MemoryStream stream = new System.IO.MemoryStream();
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(stream))
{
writer.Write(input);
writer.Flush();
}
return stream.ToArray();
}

public static string ConvertBytesToString(byte[] bytes)

{
string output = String.Empty;
System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes);
stream.Position = 0;
using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
{
output = reader.ReadToEnd();
}
return output;
}


Enjoy.

23.1.09

Microsoft Commerce Server 2009






Microsoft Commerce Server 2009 Release Candidate One

A Microsoft acaba de anunciar o lançamento do Microsoft Commerce Server 2009 RC.

Para baixar o ISO com o Commerce 2009 clique aqui

See more in:
colin Commerce WebLog

Fonte: colin Commerce WebLog

4.7.06

DotNet


Section Handlers
Understanding Section Handlers - App.config File
By Palanisamy Veerasingam
This article explains configuration section handlers defined in the System.Configuration namespace and explains how to create custom sections handlers by implemeting the IConfigurationSectionHandler interface.

HTTP Modules
One of ASP.NET's most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.

See more in:
The ASP Column: HTTP Modules -- MSDN Magazine, May 2002
by George Shepherd

Implementing an IIS Application Filter Using .NET HttpModules and Response Filtering
by Joseph Geretz

Send E-Mail from your .NET application using your GMail Account
Send E-Mail from your .NET application using your GMail Account
by Syed Moshiur Murshed

Scramble Your Query Strings
Query strings are a very convenient way of passing information to a new window or to a following page. The problem with query strings is that the information is visible. In my experience, the wiseass users see the query strings in the browser and try to duplicate the functionality: like "Oh, when I click the button, I get 'DeleteInventory.aspx?item=123&user=george&id=99' so, if I want to delete the item #222, I just need to use 'DeleteInventory.aspx?item=222&user=george&id=99' right?" Wrong, the id=99 is the database ID for the item to be removed. The rest of the information is for populating the label controls on the page. To avoid this problem, either use POST instead of GET (made much easier in ASP.NET 2.0) or scramble the information in the querystring. Nobody will make a mess with 'DeleteInventory.aspx?value=lkajhskjhsdfoiuhrt8974325lkjh'.
Scramble Your Query Strings article







2.6.06

del.icio.us - links to your favorite

What is del.icio.us?


del.icio.us is a collection of favorites - yours and everyone else's. Use del.icio.us to:



  • Keep links to your favorite articles, blogs, music, restaurant reviews, and more on del.icio.us and access them from any computer on the web.

  • Share favorites with friends, family, and colleagues.

  • Discover new things. Everything on del.icio.us is someone's favorite - they've already done the work of finding it. Explore and enjoy.


Where do I start?


Anyone can browse del.icio.us and see what others find interesting.


To keep your favorites on del.icio.us, you must
first create an account.

1.6.06

Ajax.NET Professional

Below you will find some example web pages that are using Ajax.NET to get rid of the postback in typical ASP.NET applications:

Microsoft.NET Framework 1.1
Microsoft.NET Framework 2.0

by Michael Schwarz
Google group Ajax.NET Professional.

Things you wanted to know about Microsoft Commerce Server

Commerce Server 2007: Development
by Jeff Lynch [MVP] Everything E-Commerce


I'm going to start a new series of posts related to Commerce Server 2007 to help other TAP and beta customers get started with their development work. All of these "tips" come directly from what I've learned (the hard way) over the past five months and are intended to save you time and effort.



Microsoft Commerce Server 2000 Catalog Management System: Criteria for Selecting a Catalog Management System
by Philip Reilly
Senior Consultant, Microsoft Consulting Services
May 2001

Summary: Microsoft Commerce Server 2000's flexibility leads to the following question: "When should a business use Commerce Server's catalog management system, and when should it use an external catalog system?"

This article attempts to answer the question by providing a description of the integrated catalog management system, and offering a set of criteria that should be evaluated to determine whether a business should consider an external catalog system. (50 printed pages)



.NET Class ReferenceThis section contains reference pages for objects and services used in .NET-based Commerce Server applications.


Getting the most appropriate list of catalogs for the current user

I was looking at the documentation of CommerceContext.GetCatalogsForUser and there is surprisingly very little documentation compared to what the method actually does. Based on the user browsing the site this method attempts to retrieve the most appropriate list of catalogs for that user. And this is how:

by vinayakt