Sandip's Programming Zen

An attempt to share tech/coding experiences

Posts Tagged ‘.Net

ASP.NET Webservices: “The request failed with HTTP status 401: Access Denied.” Error

leave a comment »

I have faced this issue today and thought it would be useful to share.

We can solve this issue in following way.

In IIS 7:

1. Right Click on Authentication feature and select Edit Feature.

2. Right Click on Anonymous Authentication and select Edit.

3. Either put IUSR_XXX account in Specific User or Just select Application Pool Identity (whatever works in your case).


In IIS 5/6:

1. Click “Start” – “Run” – Type “inetmgr” and press “Ok” or “Enter” Key

2. IIS Control panel opens.

3. Expand the appropriate nodes and navigate to the virtual directory of your Web Service Application.

4. Select the Virtual directory, Right Click and select “Properties”

5. Switch to the “Directory Security” Tab and then Click “Edit”.

6. Check the “Anonymous Access” CheckBox.

7. Click “Ok” twice to exit.

This should solve the issue.

Written by Sandip

November 27, 2008 at 2:10 pm

Posted in .Net, Troubleshooting

Tagged with , ,

C# 3.0 Language Enhancements

leave a comment »

I am trying to summarize some of the most visible new C# 3.0 new language features. Here they go…

Automatic properties

Create properties in a single line

public string FirstName { get; set; }

  • No internal field required
  • Similar to property interface definition
  • Easy to upgrade when logic is required

Object initialisers

Quickly initialize properties on new objects

User user = new User { FirstName=”JD” };

  • Provides short hand object creation

Collection Initialisers

Similar to object initialisers

List<User> users = new List<User>
new User(),
new User()


Extension methods

Add new methods to existing types

public static bool ReturnTrue(this string s)
return true;

  • Specific to a given namespace
  • Potential upgrade path issues

Implicit types

Infer a type

var number = 600;

int number = 600;

Type is defined at compile time (statically type)

Partial Methods

  • Methods in partial classes
    • One with implementation
    • One without implementation
  • Primary designed for code-gen

partial void MyMethod();

partial void MyMethod()


//method body


Lambda Expressions

  • Powerful addition for querying
  • Lambda calculus
  • Introduces the => operator

U => U.FirstName.Length > 5

  • Requires value on variable creation
  • Required for anonymous types


  • Language INtegrated Query
  • Provides new syntax for querying using Lambda Expressions

    If you know any more interesting features then put them in your comments here.

    Written by Sandip

    February 2, 2008 at 7:08 pm

    Posted in .Net

    Tagged with , , ,