Friday, January 31, 2014
Thursday, January 30, 2014
How to fix problem: In ASP.NET form authentication, cookie only working under compatibility mode in IE 10 or above?
In web.config file, Add cookieless="UseCookies" property into Form Authentication section
<authentication mode="Forms">
<forms cookieless="UseCookies" loginurl="/" name=".AUTH" path="/" timeout="10000">
</forms></authentication>
Reference:
http://stackoverflow.com/questions/6983732/ie10-user-agent-causes-asp-net-to-not-send-back-set-cookie-ie10-not-setting-coo
<authentication mode="Forms">
<forms cookieless="UseCookies" loginurl="/" name=".AUTH" path="/" timeout="10000">
</forms></authentication>
Reference:
http://stackoverflow.com/questions/6983732/ie10-user-agent-causes-asp-net-to-not-send-back-set-cookie-ie10-not-setting-coo
Wednesday, January 29, 2014
How to get index for foreach binding in Knockout?
The Syntax for get parent data index is:
$parentContext.$index
Tuesday, January 28, 2014
How to create AllowAnonymous Attribute in ASP.NET MVC 3?
There is one in ASP.NET MVC 4, but not in MVC 3.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public sealed class AllowAnonymousAttribute : Attribute { }
Monday, January 27, 2014
Tuesday, January 21, 2014
Monday, January 20, 2014
How to set UserName property value in customized MembershipUser class?
Because in base class UserName property is read only.
public virtual string UserName { get; }
So need to call base constructor to set the value
public virtual string UserName { get; }
So need to call base constructor to set the value
public class CustomerUser : MembershipUser { public string CID { get; set; } public CustomerUser(string username, string cid: base("CustomerMembershipProvider", username, null, null, null, null, true, false, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now) { CID= cid; } }
Friday, January 17, 2014
How to check if variable is null or empty string in JavaScript?
if(variable) {}
It will return false If variable is
empty string
NULL
undefined
Thursday, January 16, 2014
What is Reverse DNS record?
Reverse DNS lookup is the process to get designated domain name from an IP address.
http://en.wikipedia.org/wiki/Reverse_DNS_lookup
http://en.wikipedia.org/wiki/Reverse_DNS_lookup
Tuesday, January 14, 2014
Thursday, January 9, 2014
Wednesday, January 8, 2014
How to solve "Collection was modified; enumeration operation may not execute."?
For IEnumerable collection, need to use ToList first, so you can get same list during the iteration.
foreach (var qs in one.QuestionSets.ToList()) { dbc.Questions.DeleteObject(qs.Question); }
How to convert a string to json array in Javascript?
By JQuery:
Reference:
http://api.jquery.com/jquery.parsejson/
var initQuestions = '[{ "Title": "1112", "QuestionType": { "ID": 2, "Value": "1", "Text": "Text", "Selected": true}}]'; var json = $.parseJSON( initQuestions );
Reference:
http://api.jquery.com/jquery.parsejson/
How to solve "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"?
The default value for JavaScriptSerializer is 102400. Need to change before using:
JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = int.MaxValue;
Reference:
http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.maxjsonlength.aspx
Tuesday, January 7, 2014
How to solve problem "This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet"?
public ActionResult JsonRequest() { return Json(instanceOfClass, JsonRequestBehavior.AllowGet); }
Monday, January 6, 2014
How to solve problem: tinymce steal focus in ie?
setup : function(ed) { ed.onLoadContent.add(function(ed, o) { var controlLoad = setTimeout(function() { if ($('.mceIframeContainer').size()==1) { $('form *:input[type!=hidden]:first').focus(); clearTimeout(controlLoad); } }, 100); }); }Code and working example link:
http://dl.dropboxusercontent.com/u/76169930/stackoverflow/question/10944450/tinymce/examples/no_contents_inside_textarea.html
Reference:
http://stackoverflow.com/questions/10944450/is-there-a-way-to-prevent-tinymce-from-auto-focusing-on-page-load
How to set default value for Auto-Implemented Properties in C#
Auto-Implemented Properties:
public string Name { get; set; }
Not you can not modify property directly, you could put default in class constructor.
public string Name { get; set; }
Not you can not modify property directly, you could put default in class constructor.
Friday, January 3, 2014
How to deserialize json data into dynamic object in C#?
Get DynamicJsonConverter code from
https://github.com/tomvdb/coderwall-csharp-wrapper/blob/master/coderwall_api/DynamicJsonConverter.cs
https://github.com/tomvdb/coderwall-csharp-wrapper/blob/master/coderwall_api/DynamicJsonConverter.cs
string JSONdata =""; var serializer = new JavaScriptSerializer(); serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); dynamic obj = serializer.Deserialize(JSONdata, typeof(object));
Thursday, January 2, 2014
How to sovle problem "The app has declared access to network capabilities and no privacy statement was provided in the Windows Settings Charm."
Simplest way:
Reference
http://stackoverflow.com/questions/13055381/privacy-statement-windows-8-charm-settings
SettingsPane.GetForCurrentView().CommandsRequested += SettingsCommandsRequested; private void SettingsCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) { var privacyStatement = new SettingsCommand("privacy", "Privacy Statement", x => Launcher.LaunchUriAsync( new Uri("http://some-url.com"))); args.Request.ApplicationCommands.Clear(); args.Request.ApplicationCommands.Add(privacyStatement); }
Reference
http://stackoverflow.com/questions/13055381/privacy-statement-windows-8-charm-settings
Subscribe to:
Posts (Atom)