Monday, April 15, 2013

How to fix problem: missing files when publish a website in Visual Studio for ASP.NET?

In Visual Studiio, Content files need to be marked for publishing
Right click on the file missed -> Properties -> Build Action set to Content.

Thursday, April 11, 2013

How to find common items in two set of items in C#?

            var list1 = new List() { 1, 3, 4, 5 };
            var list2 = new List() { 2, 3, 4, 5 };
            var commonItems = list1.Intersect(list2);

Friday, April 5, 2013

MVC 4: facebook twitter login with oAuth

http://www.dotnetexpertguide.com/2012/08/facebook-twitter-oauth-openid-login-with-aspnet-mvc-4-application.html

Wednesday, April 3, 2013

How to set Connection: Keep-Alive in C# HttpWebRequest class ?

Cannot set by: webrequest.KeepAlive = true;
Have to set this request header by reflection
var req = (HttpWebRequest)WebRequest.Create(someUrl);

var sp = req.ServicePoint;
var prop = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic);
prop.SetValue(sp, (byte)0, null);

Reference:
http://stackoverflow.com/questions/7458556/c-sharp-connection-keep-alive-header-is-not-being-sent-during-httpwebrequest