A day with .Net

My day to day experince in .net

Archive for the ‘Amazon AWS’ Category

Amzon AWS Windows Server 2016 hosting -Could not write to output file

Posted by vivekcek on November 2, 2016

I was trying to host an ASP.NET 4.5 application in an Amazon EC2 instance (Windows Server 2016)

Then i got below error

CS0016: Could not write to output file ‘c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\6a5d994b\b5f46f1c\App_global.asax.o34wdr3q.dll’ — ‘Access is denied. ‘

We can solve this by below power shell script

$dir = "C:\Windows\Temp"
$acl = get-acl -path $dir
$new = "IIS_IUSRS","FullControl","ContainerInherit,ObjectInherit","None","Allow"
$accessRule = new-object System.Security.AccessControl.FileSystemAccessRule $new
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $dir
Advertisements

Posted in Amazon AWS | Tagged: , | Leave a Comment »

Restart Amazon AWS EC2 instance from PowerShell

Posted by vivekcek on July 25, 2016

In this post i will show you how can we restart a windows ec2 instance by using powershell.

1. Go to your account, select Security Credentials and create an AWS access key and secret key.

2

3

2. Open Power-Shell for AWS, which will ask your AWS Access key and Secret Key.

1

3. If Power-Shell not prompted for keys go to “C:\Users\Administrator\AppData\Local\AWSToolkit” and delete the Registered Account Jsonfile and open Power-Shell again.

4. Now get your instance id by using this url from EC2 instance

http://169.254.169.254/latest/meta-data/instance-id

5. Now from powershell give below command

Restart-EC2Instance -InstanceId i-12345678

Posted in Amazon AWS | Tagged: , , , | Leave a Comment »