Thursday, February 27, 2014

Tuesday, February 25, 2014

How to solve problem: 'xEntities': type used in a using statement must be implicitly convertible to 'System.IDisposable' when use using block to open Entity Framework data context?

Need to add EntityFramework.dll reference into your project file.

What is Open ID and its workflow?

OpenID allows you to use an existing account to sign in to multiple websites, without needing to create new passwords.
From:  http://openid.net/get-an-openid/what-is-openid/



OpenID 2.0 interaction sequence from Google
https://developers.google.com/accounts/docs/OpenID?csw=1#Interaction

Monday, February 24, 2014

How to avoid html tags flashing with Knockout data binding in the beginning?

Make a div to wrap up all of KO data binding elements, and make it invisible and only turn visible after KO data binding.

Thursday, February 20, 2014

How to add Bundling function into upgraded ASP.NET MVC 4 project?

1. Use nuget to add reference for System.Web.Optimization
Install-Package Microsoft.AspNet.Web.Optimization
2. Add following call into Application_Start event
 BundleConfig.RegisterBundles(BundleTable.Bundles);
3. Define your bundle
        public static void RegisterBundles(BundleCollection bundles)
        {
        bundles.Add(new ScriptBundle("~/Scripts/jquery").Include(
            "~/Scripts/Lib/jquery/jquery-{version}.js",
            "~/Scripts/Lib/jquery/jquery.*",
            "~/Scripts/Lib/jquery/jquery-ui-{version}.js")
        );
        }

Languages ranking from 2013 Stack Overflow User Survey Results

http://blog.stackoverflow.com/2014/02/2013-stack-overflow-user-survey-results/

developers_final

Thursday, February 13, 2014

How to solve problem, The length of the query string for this request exceeds the configured maxQueryStringLength value in ASP.NET?

Add following sections into web.config
  <system.web>
    <httpRuntime maxUrlLength="10000" maxQueryStringLength="2000000" />

And also in
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxUrl="10000" maxQueryString="2000000" />
      </requestFiltering>
    </security>

How to add prefix string in Knockout data binding?


ID is a observable
<h2 data-bind="text:'Transaction ID:'+ID()"></h2>

Wednesday, February 12, 2014

How to fix Access denies problem while run ASP.NET MVC project with Windows Authentication in Visual Studio 2012

Open project file with notepad
 Change
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
To
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
The full error is:
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server’s administrator for additional assistance.

How Many Software Developers Are Out There?

18 millions
http://www.infoq.com/news/2014/01/IDC-software-developers

Wednesday, February 5, 2014

How to wrap up a static html page into ASP.NET MVC Action?

Without layout, it is very easy
public ActionResult PrivacyPolicy()
        {
            //return View();
            return Content(System.IO.File.ReadAllText(Server.MapPath("~/privacypolicy.html")));
        }


With layout
In Controller
public ActionResult PrivacyPolicy()
        {
            return View();
        }
In view file
@Html.Raw(File.ReadAllText(Server.MapPath("~/privacypolicy.html")))

Tuesday, February 4, 2014

What is OR operator in CSS selector?

Comma:

h1, h2, h3 { font-family: sans-serif }

In W3 calls grouping
http://www.w3.org/TR/CSS2/selector.html#grouping

Monday, February 3, 2014

How to get visitor IP address in static method?

        protected static string GetUserIPAddress()
        {
            string VisitorsIPAddr = string.Empty;
            if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
            {
                VisitorsIPAddr = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else if (System.Web.HttpContext.Current.Request.UserHostAddress.Length != 0)
            {
                VisitorsIPAddr = System.Web.HttpContext.Current.Request.UserHostAddress;
            }
            return VisitorsIPAddr;
        }