Posts

Showing posts from September, 2016

Using native Facebook App's authentication to login to Azure Mobileservice in Universal Windows App

I used the "Facebook authentication" in Azure Mobile App service but it requires user to enter Facebook credential to login by default, and so I need to get the user token from native Facebook app and then pass it to Azure App service.  Below is the code I used to retrieve user token from native Facebook app. It will redirect user to native Facebook App to authenticate. string fbAppId = "xxxxxxxxxx"; string fbWinAppId = "xxxxxxxxxxxxx"; string FacebookURL = "https://www.facebook.com/v2.7/dialog/oauth?client_id=" + fbAppId; string callBackURL = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri; string token = string.Empty; FacebookURL += "&redirect_uri=" + System.Uri.EscapeDataString(callBackURL) + "&display=popup&response_type=token&state=1&scope=email";  System.Uri startURI = new Uri(FacebookURL);  System.Uri endURI = new Uri(callBackURL);  var resultFB = await  Windows.Sec

Fixed "String was not recognized as a valid DateTime." issue in SharePoint 2013

Image
I met the issue "String was not recognized as a valid DateTime." in a WebPart in SharePoint 2013 site. The issue was occur in a line of code: DateTime.Parse(dr["DUE_DATE"].ToString());   The code works fine in production environment and I verified the date format for "dr["DUE_DATE"].ToString()" was "10/03/2016" (Australian Date format).  I went to "Site settings"-> "Regional settings" and then changed the "Locale" drop down list to "English (Australia)" as below screenshot. Now the issue is gone and the Date time value is showing in the WebPart! 

Calling a external web service in a SharePoint 2013 WebPart

I need to call a external web service in SharePoint 2013 WebPart. The web service URL is "http://abr.business.gov.au/abrxmlsearchRPC/AbrXmlSearch.asmx". I created a ASP.NET web application to test the functionality firstly. I added a server reference as a Web reference for this web service and then using the web service call but received the "Unable connect to remote server" error. I changed to use "HttpWebRequest" e.g. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("<service url>"); and then add a "webproxy" class as below: WebProxy webProxy = new WebProxy("<proxy url>");   Set the HttpWebRequest to use above proxy request.Proxy = webProxy; But I retrieved the "HTTP 401 Not Found" error message when try to get the response: response=((HttpWebResponse)(webRequest.GetResponse()));   So I decided to use default system proxy as below: request.Proxy = WebRequest.GetSystemWebProxy

Ememded jQuery code within ASP.NET

Below is a sample code to have ememded jQuery code within ASP.NET page.  <% if (abc=="4") { %>            <script>                     $("#vist<%=x.ToString()%>").css("color","green");             </script>   <% } %> The above code will add custom CSS code to HTML element with id has string like "visit#".