Filezilla Server Passive Mode Custom Ports

If you use custom ports for passive mode, be sure to restart your FTP server service. 

Otherwise, you still cannot connect from a client even if you have setup the appropriate incoming firewall rules for those ports.

Advertisements

How to Delete Old IIS Logs with Scheduled Task

IIS can rotate log files.  I just wish it could also delete log files older than x number of days.

Since IIS 7.5 does not do it, I would have to write a quick powershell script for it.

To begin, the following will list all files within the folder/subfolders (i.e. the whole tree recursively) that is older than 30 days and match the file name pattern “u_ex*.log”.

   1: $srcPath = "C:\inetpub\logs\LogFiles\"

   2: $filePattern = "u_ex*.log"

   3: $cutoffDays = 30

   4:  

   5: # output the file names to delete

   6: Get-ChildItem $srcPath -Include $filePattern -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(0-$cutoffDays)} | out-string

 

Once you are comfortable, you can replace “out-string” with “Remove-Item”.  It will delete those old files.

   1: $srcPath = "C:\inetpub\logs\LogFiles\"

   2: $filePattern = "u_ex*.log"

   3: $cutoffDays = 30

   4:  

   5: # delete the files

   6: Get-ChildItem $srcPath -Include $filePattern -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(0-$cutoffDays)} | Remove-Item

 

Say you also want to keep a log of the files you are deleting:

   1: $srcPath = "C:\inetpub\logs\LogFiles\"

   2: $filePattern = "u_ex*.log"

   3: $cutoffDays = 30

   4: $logFolder = "C:\temp\"

   5: $logPath = $logFolder + (Get-Date).tostring("yyyyMMdd") + "_cleanuplog.txt"

   6:  

   7: # log file names to delete to a log file

   8: Get-ChildItem $srcPath -Include $filePattern -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(0-$cutoffDays)} | out-file $logPath -Append

   9:  

  10: # delete the files

  11: Get-ChildItem $srcPath -Include $filePattern -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(0-$cutoffDays)} | Remove-Item

 

Special thanks to Nathan Hartley’s powershell answer.

Reference:

http://serverfault.com/questions/315721/how-do-i-setup-iis-to-rotate-logs

http://www.howtogeek.com/204088/how-to-use-a-batch-file-to-make-powershell-scripts-easier-to-run/

MVC ASP.NET Identity OWIN Authentication Not Working for IE

Background

We have a MVC App which uses ASP.NET Identity, which uses OWIN.

We test the login authentication using 3 browsers:

  • Google Chrome
  • Firefox
  • IE 11

It works fine for all browsers in our local workstations using IIS Express and localhost.

Problem

However, when we deployed it to a test environment, IE fails to authentication while Chrome and Firefox succeeded.

The test environment is using IIS 8.

Cause

It turns out that IE does not like domain name with underscore and we were using a URL like “dev_myapp.xxxx.com”.  IE fails to cookies.

Solution

We use a different subdomain name without underscore.

Reference:

https://support.microsoft.com/en-us/kb/316112