Upload changes only to your published web site (patch your web site files)

When you publish a web site you get all the files in a .zip or in a folder.

That’s a lot of files to transfer, especially if you can’t easily publish a package or you have a slow connection to your web server.

But with each version of the web site you have only changed a few files.

So after the first publish, write a .cmd or .bat file using xcopy to put just the changed files into another folder. Something like…


xcopy MyProject MyProjectUpdate /D:2-19-2018 /S /I /Y


/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
(change this every few days, and also clear out the destination folder MyProjectUpdate )

/S Copies directories and subdirectories except empty ones.

/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.

/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.




MVC / Razor doesn’t post values from disabled html elements back to controller

In a Razor MVC form, if you disable a html element, the value won’t be posted back to the controller.

@Html.EditorFor(model => model.Person.Surname, new { htmlAttributes = new { @class = "form-control variable" } })

You might do

if (...) {
 $(".variable").attr('disabled', 'disabled'); //doesn't work

Better, do this…

if (...) {
 .prop("readonly", true)
 .css('color', "#c0c0c0");


Build Date for MVC or Visual Studio project

Shamelessly stolen from here

Project, create new folder Resources

Project, Properties: Build Events, Pre-Build event command line

echo %date% %time% > "$(ProjectDir)\Resources\BuildDate.txt"

Build your Project

Project, Resources: Create Default Resources File

..Add Resource, Existing File, …\Resources\BuildDate.txt

To read the build date, e.g. in a controller

protected override IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)

ViewBag.BuildDate = Properties.Resources.BuildDate;