This page is used for taking my notes during my daily programming works. It helps myself, of course, on quick references before searching. And I am glad if you find it useful.

ASP.NET MVC

  • Ignore a path for downloads (or accessing static files in ASP.NET MVC Web Application)

    Add a line below to the RegisterRoutes() method in the RouteConfig.cs file.

    routes.IgnoreRoute("Downloads/*");
    

    or to ignore all

    routes.IgnoreRoute("");
    

    Full class

    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
            // allow to access static files under /Downloads/*.* = no routing this path to Controller in MVC
            routes.IgnoreRoute("Downloads/*");
            //routes.IgnoreRoute("");
    
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
    

Front-End Libraries (CSS, HTML, JavaScript, jQuery plugins…)

Newtonsoft Json.NET

  • JToken

    Link: https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Linq_JToken.htm

    The JToken hierarchy looks like this:

    JToken              - abstract base class     
        JContainer      - abstract base class of JTokens that can contain other JTokens
            JArray      - represents a JSON array (contains an ordered list of JTokens)
            JObject     - represents a JSON object (contains a collection of JProperties)
            JProperty   - represents a JSON property (a name/JToken pair inside a JObject)
        JValue          - represents a primitive JSON value (string, number, boolean, null)
    

EF & EF Core

  • Differences in connection string

    2 flashes \\ in connection string Server=(LocalDB)\\MSSQLLocalDB in appsettings.json file

    {
        "ConnectionStrings": 
        {
            "DefaultConnection": "Server=(LocalDB)\\MSSQLLocalDB;Database=AppDb;Trusted_Connection=True;"
        }
    }
    

    but ONLY 1 flash \ in connection string Server=(LocalDB)\MSSQLLocalDB in dotnet ef dbcontext scaffold command

    dotnet ef dbcontext scaffold "Server=(LocalDB)\MSSQLLocalDB;Database=AppDb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models