4
03
2011
If you’ve used Visual Studio 2008 or 2010, you’ll notice that Web Reference is no longer there (like in VS 2005 and previous), instead, you see Service Reference –- actually, it’s STILL there, just hidden!
So, what’s the difference? Well, according to this post:
Add Web Reference is the old-style, deprecated ASP.NET webservices (ASMX) technology (using only the XmlSerializer for your stuff) – if you do this, you get an ASMX client for an ASMX web service. You can do this in just about any project (Web App, Web Site, Console App, Winforms – you name it).
Add Service Reference is the new way of doing it, adding a WCF service reference, which gives you a much more advanced, much more flexible service model than just plain old ASMX stuff.
So, how do you access it? Simple — right-click on Service References in the Solution Explorer window and…

Click on “Advanced…”

Then click on “Add Web Reference…”

Voila! You can now consume the web service like you did pre-Visual Studio 2008 era. Happy coding!
Comments : No Comments »
Categories : ASP.NET, General Development, Microsoft, Resource
29
07
2010
Adding for archival purposes…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
namespace Classes
{
public class Hash
{
public Hash()
{ }
#region Hash Choices
/// <summary>The wanted hash function.</summary>
public enum HashType : int
{
/// <summary>MD5 Hashing</summary>
MD5,
/// <summary>SHA1 Hashing</summary>
SHA1,
/// <summary>SHA256 Hashing</summary>
SHA256,
/// <summary>SHA384 Hashing</summary>
SHA384,
/// <summary>SHA512 Hashing</summary>
SHA512
} /* HashType */
#endregion
#region Public Methods
/// <summary>Generates the hash of a text.</summary>
/// <param name="strPlain">The text of which to generate a hash of.</param>
/// <param name="hshType">The hash function to use.</param>
/// <returns>The hash as a hexadecimal string.</returns>
public static string GetHash(string strPlain, HashType hshType)
{
string strRet;
switch (hshType)
{
case HashType.MD5:
strRet = GetMD5(strPlain);
break;
case HashType.SHA1:
strRet = GetSHA1(strPlain);
break;
case HashType.SHA256:
strRet = GetSHA256(strPlain);
break;
case HashType.SHA384:
strRet = GetSHA384(strPlain);
break;
case HashType.SHA512:
strRet = GetSHA512(strPlain);
break;
default:
strRet = "Invalid HashType";
break;
}
return strRet;
} /* GetHash */
/// <summary>Checks a text with a hash.</summary>
/// <param name="strOriginal">The text to compare the hash against.</param>
/// <param name="strHash">The hash to compare against.</param>
/// <param name="hshType">The type of hash.</param>
/// <returns>True if the hash validates, false otherwise.</returns>
public static bool CheckHash(string strOriginal, string strHash, HashType hshType)
{
string strOrigHash = GetHash(strOriginal, hshType);
return (strOrigHash == strHash);
} /* CheckHash */
#endregion
#region Hashers
private static string GetMD5(string strPlain)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
MD5 md5 = new MD5CryptoServiceProvider();
string strHex = "";
HashValue = md5.ComputeHash(MessageBytes);
foreach (byte b in HashValue)
{
strHex += String.Format("{0:x2}", b);
}
return strHex;
} /* GetMD5 */
private static string GetSHA1(string strPlain)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
SHA1Managed SHhash = new SHA1Managed();
string strHex = "";
HashValue = SHhash.ComputeHash(MessageBytes);
foreach (byte b in HashValue)
{
strHex += String.Format("{0:x2}", b);
}
return strHex;
} /* GetSHA1 */
private static string GetSHA256(string strPlain)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
SHA256Managed SHhash = new SHA256Managed();
string strHex = "";
HashValue = SHhash.ComputeHash(MessageBytes);
foreach (byte b in HashValue)
{
strHex += String.Format("{0:x2}", b);
}
return strHex;
} /* GetSHA256 */
private static string GetSHA384(string strPlain)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
SHA384Managed SHhash = new SHA384Managed();
string strHex = "";
HashValue = SHhash.ComputeHash(MessageBytes);
foreach (byte b in HashValue)
{
strHex += String.Format("{0:x2}", b);
}
return strHex;
} /* GetSHA384 */
private static string GetSHA512(string strPlain)
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
SHA512Managed SHhash = new SHA512Managed();
string strHex = "";
HashValue = SHhash.ComputeHash(MessageBytes);
foreach (byte b in HashValue)
{
strHex += String.Format("{0:x2}", b);
}
return strHex;
} /* GetSHA512 */
#endregion
}
}
Comments : No Comments »
Categories : ASP.NET, How-to
12
07
2010
Have you ever come across the error below with one of your ASP.NET web apps that is trying to write to the Eventlogs? If so, read on…
By default the ASPNET user cannot access the existing eventlogs categories. To resolve this, you must set the permissions in the Eventlog key in the registry:
- Launch RegEdit.
- Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\.
- From the menu, select Edit->Permissions.
- Click the Add button and write ASPNET (if ASP.NET is running under a different User ID, use that ID instead).
- Click OK.
- Select the newly added user from the list (ASP.NET Machine User by default).
- Click on Full Control in the Allow column. 8. Click OK.
More info here.
Comments : No Comments »
Categories : ASP.NET, General Development, How-to
24
05
2010
Below is a summary of the “two top things that cause trouble in production ASP.NET web sites,” per Scott Hanselman, which he obtained from deep within Microsoft Developer Support. Go here to read the complete article.
#1 Issue – Configuration
Seems the #1 issue in support for problems with ASP.NET 2.x and 3.x is configuration.
| Symptoms |
Notes |
OOM Performance High memory Hangs Deadlocks |
There are more debug=true cases than there should be. |
#2 Issue – Problems with an External (non-ASP.NET) Root Cause
Sometimes when you’re having trouble with an ASP.NET site, the problem turns out to not be ASP.NET itself.
| Issue |
Product |
Description |
Symptoms |
Notes |
| Anti-virus software |
All |
Anti-virus software is installed onto Servers and causes all kinds of problems. |
- Application restarting
- Slow performance
- Session variable are null
- Cannot install hotfix
- Intermittent time outs
- High memory
- Session lost
- IDE Hangs
- Deadlocks
|
This consists of all AV software reported by our customers. All cases do not report the AV software that is being used so the manufacturer is not always known.
KB821438, KB248013, KB295375, KB817442
|
| 3rd party Vendors |
All |
This is a category of cases where the failure was due to a 3rd party manufacturer. |
- Crash
- 100% CPU
- High memory
- Framework errors
- Hang
|
The top culprits are 3rd party database systems, and 3rd party internet access management systems |
| Microsoft component |
All |
Microsoft software |
- Intermittent time outs
- High memory
- Deadlocks
- 100% CPU
Crash
|
Design issues that cause performance issues like sprocs, deadlocks, etc. Profile your applications and the database! (Pro tip: select * from authors doesn’t scale.) Pair up DBAs and programmers and profile from end to end |
Comments : No Comments »
Categories : .NET, ASP.NET, Microsoft
27
12
2007
Just sign up with your Windows Live/Passport account and you can download all three e-books by Microsoft Press. It includes the following:
Enjoy!
Comments : No Comments »
Categories : .NET, ASP.NET, Deals, Microsoft, Resource, Web 2.0, Web Development