Posts

Showing posts with the label WCF

How to avoid a CORS problem?

This summary is not available. Please click here to view the post.

My Learnings with current Mobility/Web market trend

Hi, First of all a big happy new year to all my visitors. Today I would like to share my learning about the current market trend as the winter is going to complete and all the market will start to bounce back in next 30-45 days. At the starting of my career I used to be in a big misconception like any fresher. I always think ASPX, PHP, JSP, CFM etc are far better than the plain HTML pages. I really felt painful to write plain prototype based html with javascrript. But now after seeing the market trends and mobility boom I realized the true strength & can confidently say it like HTML is far far away from any other above mentioned server based web technologies. In the coming future the only UI we will see with is developed only with HTML5. Question : So WHY previously we didn't concentrated on these things, Because HTML already there and which works only via http protocol means we have web services etc to work on. Answer : Previously the handshakes will be based on SOA...

Generate random string using c#

Hi, Today am blogging a simple concept related to generating a random sring. In realtime it will be used mainly for generating captcha, random password, Temporary objects etc. Here we can send the string length expected. Also You can modify he complexity. Its a simple code and easily understandble. Here is the code snippet. /// /// Creates the random string based on the length provided /// /// Length of the password. /// public static string generateRandomString(int PasswordLength) { string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789"; Random randNum = new Random(); char[] chars = new char[PasswordLength]; int allowedCharCount = _allowedChars.Length; for (int i = 0; i < PasswordLength; i++) { chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())]; } return new string(chars); } hope it helps you. Regards, Pavan N

Download file using WCF REST services

Hi, Generally we used to download a file using a handlers and sending parameters as a querystring (lets say download.ashx). Here few cases we might need to impersonate the user also. It purely depends on environment. Here is a sample code snippet just for reference. if (extension.Trim() == ".pdf") { context.Response.Clear(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", "attachment;filename=" + queryFile + ".pdf"); context.Response.BinaryWrite(System.IO.File.ReadAllBytes(file)); } But instead of that we can download a file as a stream using a WCF REST service too. Here is the code snippet for declaration in interface .. /// <summary> /// To fetch documents /// </summary> /// <param name="filePath">Represent text of filepath</param> /// <param name="fileName">Represents text of filename...