+1  A: 

The problem is probably that you need to supply a session cookie with your login request.

What you need to do is first make a normal GET request to the login page. Add all response cookies to your CookieContainer and then use the same CookieContainer when making the actual POST login request.

Also, try and mimic the real request as much as possible. Use the same Referer value etc.

Have a look at this question http://stackoverflow.com/questions/3359762/logged-in-to-purevolume-com-programatically/3359934#3359934

Edit: Depending on how the site you are trying to login to is designed you might need to parse and supply the ViewState data as you suggested. But since an initial GET request most likely already is required this shouldn't be to hard to do.

Jesper Palm
Jesper - thanks a bunch. Will try it. I have managed to parse the viewstate and other input values from GET and have been able to reproduce the POST - the only thing missing now are the cookies! I will do what you suggested and post back on what I have. (After I fixed the POST input values, I get an error response page - at least a different response! I suspect it's because of cookies)
Gerry
Jesper - I have more to report. My GET and POST are consistent with IE. With the browser I can login, but with my POST I get a 302 with a error page. There is just one difference - IE does this:- GET- POST (success), and this post has cookies (3 pieces of which one is ASP session ID)mine:-GET-POST (failure), has cookies, but only 1 (which is a ASP session id), the other cookies don't show up.Everything else is fine - and I did look at the link you added and did exactly that for cookies, but no luck! What am I missing? This is driving me nuts!
Gerry
Do you see the missing cookies in the response from your initial GET request in Fiddler?
Jesper Palm
No I don't - that's the annoying thing. But then when I tried a new IE session, the first GET shows no cookies, but the subsequent POST shows all of them (in fiddler). For me, the GET gets me the ASP.NET_SessionId= cookie and nothing else. So when I POST, that's the only cookie I have and the page seems to reject it. My GET is pretty much exact as the browser GETs, the only difference is mine is a desktop console app. What am I missing?
Gerry
If the cookies isn't returned by the response then they are set by a client side script, ie JavaScript. Check the page source and look for any javascript setting cookies.
Jesper Palm
Jesper, it appears so! There's a JS script that's getting included at end of the page and it has a whole lot of cookie related code. Sorry to be thick - I've never ever done anything like this before, but is there a way I can read it? I mean I'm just doing a GET so presumably the JS isn't getting extracted etc. The other desktop app apparently is pulling this off in some way...I'm a bit lost now. Will keep researching, thanks.
Gerry