ASP.NET News from Blogger: hongmeigs WebLog   Get the feed of: hongmeigs WebLog

Total News: 47

Config based activation in WCF

There is a cool WCF feature instroduced in dev10 called configless activation. You don't have to have a *.svc file in your web directory, instead you can activate a WCF service using the following con...

Why does the MaxReceiveMessageSize in WCF matter in case of Streaming

The default value of MaxReceiveMessageSize in WCF is 65,536.  When you choose streaming as TransferMode, WCF runtime will create 8192 as buffer size. So what happened now is that WCF channel...

Timeouts in WCF and their default values

  There are a lot of timeouts in WCF. let us summarize it here. Timeouts on binding These are the most well known timeouts. SendTimeout, ReceiveTimeout, OpenTimeout and CloseTimeo...

How to solve System.InvalidOperationException: For request in operation Test to be a stream the operation must have a single parameter whose type is Stream

 You are getting this error because the default WCF stream formatter does not support this. You are probably trying to upload some file stream and transfer some other parameters, such as file nam...

how to turn off the auto-redirect feature in WCF REST 4.0

Missing a trailing slash is a common error people make when browsing the web. For better usability, in 4.0, we introduced a feature called autoredirect. It is on by default, meaning, when you set up y...

A possible solution to a common sql error

If you happen to get the following sql error:    An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005 or above, this failure may be ca...

WCF error: Cannot resolve KeyInfo for unwrapping key: KeyInfo 'SecurityKeyIdentifier

If you are getting an error like : Cannot resolve KeyInfo for unwrapping key: KeyInfo 'SecurityKeyIdentifier and your have checked that your certificate is in the right store and right place. So this...

How to pass custom object between WCF client app and custom issued security token provider

There are two options: 1. OperationContext.Current. Pros: This is pretty straightforward and relatively hard to discover.  Cons: This is a thread local storage, and you are invoking a ...

Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances

If you are getting the following error: Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances What should I do?   Answer: To fi...

How to use findstr with regular expression

By default findstr does the comparison with regular expression. However, what surprised me is that the following command does not work.  findstr "abc|def" test.txt when test...

How to make IIS hosted WCF service work with Card Space using localhost

First let me explain why it does not work. There are three string comparisons done by card space. The information card has Issuer, IssuerEndpointAddress, and IssuerMexAddress. When you...

How to change your web site from https://localhost to https://mydomain.com

There are three steps you need to take to make it work.  1. Modify your hosts file under \Windows\System32\drivers\etc\hosts and add the following entry: 127.0.0.1    mydomain...

How do I turn on windows authentication in IIS 7

In IIS 6, you can start the IIS manager by typing the inetmgr at the Start->Run windows, and click on the web site, Right click on the web site, go to the directory security, you will have windows ...

Make the WCF service take the personal card

The common error that users will run into for the personal card scenario is that the WCF service cannot verify the signing credentials of the saml token. This is because the personal card will trigger...

Card Space exception: incoming policy failed validation

One possibility is that your binding does not contains required claim types. In your client binding, make sure you have at least one required claims: WSFederationHttpBinding binding = new WSFederation...

CardSpace: Why can't i select my personal card

You need to make sure that your personal card contains the required claim types you specified in your client binding. To fix this, try set the required claim types to one of the claims that your perso...

Turning on trace for WCF

First you need to download some windows sdk tools. You can get those from http://www.microsoft.com/downloads/details.aspx?FamilyId=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en. Only check t...

WCF exception: The remote certificate is invalid according to the validation procedure

If you are using Https, this might fix it.             ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallb...

CardSpace UI not popping up

What could go wrong when cardspace UI is not popping up? You can see if you have card space UI working properly on your box by go to Control Panel->Windows CardSpace. The correct behavior is t...

How to do authorization based on the body content

This is a forum question, and here is a very sneaky way to do so. protected override bool CheckAccessCore(OperationContext operationContext) {     string msgStr = operationContext.Reque...

How to setup SSL on Vista with IIS 7

IIS 7 has a new UI which is different from the previous version. Here I am going to talk about how to set up the SSL via the new UI. It is a different user experience for setting up the ssl certificat...

What happened behind the scene in Card Space

Yes, i am sure quite a lot of people have already seen the great card space UI. But if you are like me who wants to understand the message flow and what is in the card, here are the answers. First,&nb...

The CAPICOM library failed to load might be caused by permission

A clean installation of Vista, download the card space sample from http://cardspace.netfx3.com, and download the Simple WPF based smartclient application, run the install.bat for setup, i got the foll...

Download "Simple WPF based Smartclient application" sample today

"Simple WPF based Smartclient application" sample from http://cardspace.netfx3.com/files/default.aspx is an excellent sample to learn how self issued info card are being used. The caching behav...

Serialization magic with DataContract attribute in WCF

I want to serialize something similar to this format: <Body>       <Response>               &...

Custom Identity verifier

 Getting identity verifier error? Here is one way to work around it.  securityBindingElement.LocalClientSettings.IdentityVerifier = new CustomVerifier(); And Here is an example of how this c...

Best fonts for doing demo using VS

For presentation, start VS, go to Tools->Options, under Environment/Fonts and colors, choose Lucida Console, and font size 14. Choose Courier New, and font size 10 for writing code.  ...

How to distribute my public key portion of the cert to the Client in an "SSL" fashion

Distributing x.509 is always a painful thing, and using WCF, it no long is. In the WCF configuration, there is a knob in the configuration which helps the client to get the public key portion of the c...

What cert shall i use for WSE 3.0

If you are going to request one certificate from a cert authority, then you probably need to explicitly ask for the following key usages: Digital Signature, Key Encipherment and Data Encipherment. Use...

configuration entry intellisense

Wondering how do you ever get intellisense while writing configuration files using VS? Here is why? All the scchemas for VS are defined at {...}\VisualStudio\bin\i386\xml\schemas\dotNetConfi...

403.1 error while hosting WCF service using IIS

If you are getting 403.1 error while hosting WCF using IIS, then you might be using the wrong directory name. Let us say you want to host your service at http://localhost/A/service.svc  And the ...

The .svc page only show the text value of the .svc file

Your IIS needs to link the .svc extension to the aspnet_isapi.dll. You can this by right click on your v-root from IIS manager. on the virtual directory tab, click on the Configuration button, and you...

Automatically adding WSE2 dll to the VS 2005 web service project

Make sure that you don't have any reference in your code which still refer to the WSE 2 dll. VS 2005 will auto add the assembly reference when you build the web site project....

Perf issue with X509Certificate2.Extensions with the OID look up

If you are running into some perf issue with using X509 certificate in WSE 3.0 or .NET Framework 2.0, here might be the reason. There is a known perf issue to do X509Certificate2.Extensions OID&n...

How to traverse xmlelement.childnodes effectively

I have been working on the performance these days, and I want to share some tricks that you can do to reduce memory allocation significantly if the xml document you are working with is huge. Use XmlEl...

Check XmlElement.HasAttributes before calling XmlElement.Attributes

I have tested it against Everrette. If an xmlelement you are working with doesn't contain any attributes, calling XmlElement.Attributes will trigger the system to create an empty ArrayList. The best w...

WSE2 SP2 released today

This release fixes some top customer issues and provide a new security token, KerberosToken2, which supports impersonation, windows constrained delegation.  The new token also works wel...

How to let ASPNET process run the Whidbey bits

This should be quite easy.  After installing the right version of Whidbey, go to your framework directory, and run aspnet_regiis.exe under the whidbey directory. >cd \WINDOWS\Microso...

System.Runtime.CompilerServices.InternalsVisibleTo works

This is a very sneaky feature which has been discovered or blogged by quite a few .net gurus.  I just want to give a simple example as how to declare it properly.  Let us say you are develop...

Private Key is not available

When you use X509Certificate to encrypt a message, sometime you will see an error like "Private Key is not available".  Here is the list you want to check first: 1. Permission problem...

SymmetricKeyEncryption in WSE 2.0 ( part 2 )

As promised, i would talk about a second approach to achieve symmetric key based encryption in WSE 2.0. First, you need to create a simple hello world web service with a client project and a web ...

Symmetric key based encryption in WSE 2.0 ( part 1 )

In WSE 1.0, symmetric key encryption could be done through decryption key provider.  Moving to WSE 2.0, every security operation has been bound with a security token, including the symmetric key ...

SecurityTokenManager in WSE 2.0

The idea of SecurityTokenManager is very powerful.  It provides one single place to extend the WSE built-in token infrastructure.   You can only have one t...

Marshal.Sizeof(typeof(char)) is not equal to sizeof(char)

Yes, believe your eyes.  Marshal.SizeOf(typeof(char)) = 1, however sizeof(char)  = 2.  Reason Not sure about the first one, i guess it is traditional C style while char used to be defin...

WSE 2.0 SP1

In case you don't know, WSE 2.0 SP1 has already shipped.  You can download it from http://www.microsoft.com/downloads/details.aspxFamilyId=FC5F06C5-821F-41D3-A4FE-6C7B56423841&displaylang=en ...

WSE 2.0 RTM

Yes!  The second version of Web Service Enhancements for Microsoft .NET has recently shipped!  There are a lot of excitement and enthusiasms about WSE 2.0 RTM. The release wa...

About me

Currently, I am a developer in Adanced Web Services team.  The product I am working on is called Web Services Enhancements, commonly known as WSE.  It is my first te...

View Other bloggers