Sunday, October 6, 2013

HTTP Error 403.14 - Forbidden - the web server is configured to not list the contents of this directory

Scenario:

In WCF, I was receiving the below error while trying to run the WCF client application.

HTTP Error 403.14 - Forbidden - the web server is configured to not list the contents of this directory

Solution:


Adding the below lines within the WCF Client application's web.config file, I could finally get rid of the issue and I could run the client application successfully..



Saturday, September 21, 2013

Replacement of Controller.ReadFromRequest in ASP.NET MVC

Replacement of Controller.ReadFromRequest in ASP.NET MVC

I was attempting to update a project from old version of MVC to new version of ASP.NET MVC and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class.

Upon doing some research in Google, I came across an extension method which works similar to old ReadFromRequest method. The extension method is:

public static class MyBindingExtensions
    {
        public static T ReadFromRequest(this Controller controller, string key)
        {
            // Setup
            HttpContextBase context = controller.ControllerContext.HttpContext;
            object val = null;
            T result = default(T);

            // Gaurd
            if (context == null)
                return result; // no point checking request

            // Bind value (check form then query string)
            if (context.Request.Form[key] != null)
                val = context.Request.Form[key];
            if (val == null)
            {
                if (context.Request.QueryString[key] != null)
                    val = context.Request.QueryString[key];
            }

            // Cast value
            if (val != null)
                result = (T)val;

            return result;
        }
    }

Saturday, February 16, 2013

LINQ error "Object reference not set to an instance of an object." while using 'Contains' for filtering data

Scenario:

Getting the LINQ error "Object reference not set to an instance of an object." while using 'Contains' for filtering data in the source code below:


var filteredlist = lstXXX.Where(c => c.<Property Name>.Contains(search string));

Solution:

It is required to include the Not NULL condition/s or Hasvalue==true for the properties considered in the Where clause as shown in below statement.

Otherwise the LINQ error "Object reference not set to an instance of an object." gets raised in the application.

var filteredlist = lstXXX.Where(c =>c.<Property Name>!= null && c.<Property Name>.Contains(search string));















VS Code # Warning - npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead

Error : VS Code - NPM Warning - npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead Solution:  Foll...