Posts

MVC 70-486: Chapter 1

Afbeelding
Objective 1.1: Design the application architecture Routes and routing De routing engine weet niks van MVC af. Zijn enige taak is de URL te analyseren en de controle over te dragen aan de route handler. De route handler gaat op zoek naar een HTTP handler, of een implementatie van IHttpHandler. De default HttpHandler is de MvcHandler. Deze handler extraheert de controller informatie door de request te vergelijken met de template waarden in de routing tabel. De handler haalt de strings eruit en stuurt deze naar de controller factory die op zijn beurt de geschikte controller teruggeeft. Asynchronous controllers Een grote aanpassing in MVC 4 t.o.v. MVC 3 zijn asynchrone controllers. In MVC zijn deze nu standaard opgenomen terwijl in MVC 3 gebruik maakte van een AsyncController.  Async controllers zijn handig voor niet  CPU-gebonden requests. Bij het maken van Action methods moet bepaalt worden of deze async moeten zijn of niet. Dit hangt af of de actie network- of I/O gebonden

Design Tips

Dependencies Stel Class A heeft aan afhankelijkheid van Class B, maar om Class B te kunnen instantieeren is Class C nodig. Dus Class A heeft om deze reden nu ook een afhankelijk nodig naar Class C. Met andere woorden, de implementatie van Class B is 'leaked out' en dwingt daarmee zijn gebruikers een afhankelijk te creeeren naar een Class die zij helemaal niet kennen / nodig hebben. In dit soort situatie komt de Factory Design Pattern om de hoek kijken. Class A is nu niet meer afhankelijk van Class B, maar van de Factory van Class B. Deze factory kent alle afhankelijkheden wel en zorgt er voor dat Class B op juiste wijze kan worden gecreeerd. Deze factory wordt vaak in Class A geinjecteerd middels een Depency Injection framework.

Assembly name opnemen in Entity Framework connections string

Voorbeeld:

.Net IL tools

Lijst met gratis en commerciƫle IL Tools: https://www.agile-code.com/blog/list-of-microsoft-net-il-disassemblers/

SQL blocking queries bekijken

Check de tabel 'sys.dm_exec_requests' om queries in te zien die op dit moment lopen. Er wordt daarbij aangegeven wat hun blocking PID is en wat voor WAIT het betreft. SELECT * FROM sys.dm_exec_requests

Log4net

Instellen : - Zet in het project log4net.config 'copy to output dir'  op 'true'; - In app.config: <appsettings><add key="log4net.Config" value="Log4Net.config"></appsettings> - Voorbeeld log4net.config: <?xml version="1.0" encoding="utf-8" ?> <log4net debug="true"> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\temp\loggerpoc.txt" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="250KB" /> <staticLogFileName value="true" />

XCopy parameters

Syntax       XCOPY source [destination] [options] Key    source      : Pathname for the file(s) to be copied (accepts wildcards).    destination : Pathname for the new file(s).      [options] can be any combination of the following:     Source Options       /A    Copy files with the archive attribute set (default=Y)    /M    Copy files with the archive attribute set and          turn off the archive attribute, use this option          when making regular Backups (default=Y)                                      /H    Copy hidden and system files and folders (default=N)    /D:mm-dd-yyyy          Copy files changed on or after the specified date.          If no date is given, copy only files whose          source date/time is newer than the destination time.    /U    Copy only files that already exist in destination.      /S    Copy folders and subfolders    /E    Copy folders and subfolders, including Empty folders.          can be used to modify /T.    /EX