Thursday, July 28, 2016

Renew Existing Certificate

https://robindotnet.wordpress.com/2010/01/26/how-to-extend-an-existing-certificate-even-if-it-has-expired/


Tuesday, July 26, 2016

Error trying to publish a web site from VS 2015 to Azure

If you try to publish your web site to Azure using VS 2015, you may face following error.
Can't find existing loaded project:http://localhost:6002

        ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
        ========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

To overcome that error, 
Open VS, go to View --> Other Windows --> Web Publish Activity
Click on Publish icon in there and it should do it. 

Tuesday, July 12, 2016

Wednesday, July 6, 2016

How to efficiently deal with Nuget packages version conflict in large solution.



  • Maintain a common Folder will be used as the package source and all projects should use that common source as nuget package source.

  • On the build server or developer machine the only source for the nuget packages will be this package source. We'll disable the other nuget sources on the server.
  • So if by mistake anyone add the nuget package from nuget.org, it will be caught during build as build server won't find that version package on the build server.

  • You can also manage the package at solution level. This will give you option to view the nuget version for the each of the project in the solution and then you can update them all at once to the latest version.


  • You can set local repository from the nuget package window in visual studio.



View Currently executing Requests in IIS

Go to InetMgr, go to the worker processes, double click the one you want to monitor.

or you can run following command to have more control

%windir%\system32\inetsrv\appcmd list requests /elapsed:10000
This will show all request which are execugint for more than 10 seconds. 
If you see the new requests are queuing and existing request keep taking more time then you are having a hang. Better to take the dump of the worker process using Debug Diag in such case and then analyze it for the root cause of the hang.

View Currently executing Requests in IIS

Go to InetMgr, go to the worker processes, double click the one you want to monitor.

or you can run following command to have more control

%windir%\system32\inetsrv\appcmd list requests /elapsed:10000
This will show all request which are execugint for more than 10 seconds. 
If you see the new requests are queuing and existing request keep taking more time then you are having a hang. Better to take the dump of the worker process using Debug Diag in such case and then analyze it for the root cause of the hang.

Wednesday, June 22, 2016

Azure Web Site Deployment Slots

All you need to know about Deployment Slot
https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/

And in order to prevent the access of your staging site to only white listed ips use following URL Rewrite rule.

<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
<match url=".*" />
<conditions>
<!-- Enter your staging site host name here as the pattern-->
<add input="{HTTP_HOST}" pattern="^ruslany\-staging\." />
<!-- Enter your white listed IP addresses -->
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>
<!-- Add the white listed IP addresses with a new condition as seen below -->
<!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"
statusDescription="Site is not accessible" />
</rule>




Wednesday, June 1, 2016

Tuesday, March 29, 2016

Update Reference Path in all project in solution

Run the command in Package Management Console
Run following command to set a hard coded path.

foreach ($proj in get-project -all) {$proj.Properties.Item("ReferencePath").Value="E:\Devlopment\PaperSave5.3\Development\3rdPartyLibs\"}


We can go use relative path as below.

$path = [System.IO.Path];
$proj.Properties.Item("ReferencePath").Value="$($path::GetDirectoryName($proj.filename))\..\libs"


Thursday, March 24, 2016

Infinite Loop After Login using Owin in Azure Web Site/App

Make sure to browser your app using https.

If you browse the url from portal it is with http and for whatever reason, it goes to infinite loop.
if you use https, then it works fine. still mystry why azure portal shows http and it doesnt work.

Issue with IIS Express in VS

Issue:
You cannot browse the site from VS if using https and iisexpress.

Few Tips

use command netsh http show sslcert > sslcert.txt 
and find the port of your app.
see the hash of the certificate. now to go mmc -- certificate snap --> local machine and personal.
find the localhost - iis development certificate and see the hash of it.
make sure that hash of the certificate is same in the sslcert.txt.
if not then you need to delete the the http entry and add it back.
here is how
netsh http delete sslcert ipport=0.0.0.0:44303
Use Your port above.
netsh http add sslcert ipport=0.0.0.0:44303 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=38b305a5d21cba8bcb45fa03069ad4b6940097f9


Use hash of your certificate.
and app id is a new guid.

It should work after this.



Wednesday, March 2, 2016

Create Assymetric key on Remote database

Issue here is that if you are creating it from physical assembly then you need to copy it manually on the db server.

Solution is to use assembly bits. but that would create issues while creating assembly in master db with external access. and you dont want to set trustworty to off for mater .not even for a while.
fix is that we give the permission set as safe to the assembly that we are creating in master. as assembly in master is oinly going to use to create assymetric key, you should be ok.


http://stackoverflow.com/questions/9059912/asymmetric-key-creation-over-network
http://www.sqlservercentral.com/articles/SQLCLR/74377/

Tuesday, March 1, 2016

Azure CDN

Create Azure CDN
-- Create Profile
--Create endpoint that points to the target which can be either Storage/WebApp/CustomOrigin etc.

https://azure.microsoft.com/en-us/documentation/articles/cdn-create-new-endpoint/

https://azure.microsoft.com/en-us/documentation/articles/cdn-how-to-use-cdn/

Question: How the content of the CDN get refreshed and reflect on the client ?


Monday, February 29, 2016

Hyper V and VMWare on the same machine

If you get, "internal error" while starting a VM, please start "VMware Authorization Service" Service. and try again.
To do this open an Administrator Command Prompt, enter this command and then reboot:
bcdedit /set hypervisorlaunchtype off
Hyper-V can be enabled again with this command (which also requires a reboot):
bcdedit /set hypervisorlaunchtype auto

Ref : https://pricklytech.wordpress.com/2014/02/25/windows-8-1-vmware-player-and-hyper-v-are-not-compatible/

Wednesday, February 24, 2016

Globally Accessible Class

public class GloballyAccessibleClass
    {
        private GloballyAccessibleClass() { }

        public static GloballyAccessibleClass Instance
        {
            get
            {
                IDictionary items = HttpContext.Current.Items;
                if (!items.Contains("PaperSave"))
                {
                    items["PaperSave"] = new GloballyAccessibleClass();
                }
                return items["PaperSave"] as GloballyAccessibleClass;
            }
        }

        //public HostedEnvironment PaperSaveEnvironment { get; set; };

    }

Tuesday, February 23, 2016

IIS Log Viewer

https://www.weblogexpert.com/info/IISLogs.htm

Log Parser

Covert the time

LogParser.exe "SELECT DATE,TO_LOCALTIME(time) AS time,s-ip,cs-method,cs-uri-stem,cs-uri-query,s-port,cs-username,c-ip,cs(User-Agent),sc-status,sc-substatus,sc-win32-status,time-taken INTOc:\ayman\output.log FROM c:\ayman\input.log" -i:IISW3C -o:W3C


Wednesday, February 17, 2016

ADFS 3.0 stops working after reboot

Background :
With the arrival of ADFS 3.0 in Windows Server 2012 R2 the use of IIS with AD FS in Windows Server 2012 R2 has been eschewed in favour of a move to kernel-mode (HTTP.SYS). The motive is to improve performance, provide greater sign-in customization options and to be able for co-locating ADFS and AD Domain Services on the same server (IIS on domain controllers is from a security perspective a big no-no).
As the use of federation services goes more mainstream in everyday use with Windows 8.1, office 365 , intune , azure and whatever cloud service they come up with , this shift is understandable and an important design consideration.  With the new kernel-mode approach, support for running under server core also appears as an option in the new release.
Problem :
In my lab , I Installed and configured ADFS 3.0 om my domain controller with a global managed service account (gmsa). This is a new feature since ADDS 2012 was introduced. After a server reboot , the ADFS services cannot start anymore and it always stay in "starting" state , making your DC unusable.
This issue appears to be gMSA related, when you install ADFS 3.0 on a 2012R2 running AD DS, than after the reboot (not always) gMSA fails to authenticate on behalf of the ADFS Service under which the service is configured to run.
Solution:
After investigation, I found an unacceptable workaround, which is to :
1. Reboot the ADDS/ADFS3.0 server, logon and immediately set the ADFS Service from Automatic (Delayed) to Manual.
2. Change the Microsoft Key Distribution Service (kdssvc) service to auto (instead of manual trigger) and restart the DC.
3. Logon and start the ADFS service (starts successfully)
4. Set the ADFS Service from Manual to Automatic (Delayed) .
5. Done.
Keep it coming. We’re all learning ADFS 3.0 for Windows Intune  :-)

Enable Basic Authentication in IIS Express

go to
%USERPROFILE%\Documents\IISExpress\config\applicationhost.config: 
and then search for basicauthentication in there and set it to true.

<basicAuthentication enabled="true" />


Sunday, January 31, 2016

Change Feature Delegation for IISExpress

IIS EXPRESS - TURNING ON WINDOWS AUTHENTICATION

 
 Posted In: iis
Time to Read: 1 min
So I brought up a new machine and tried to run my ASP.NET web site in IIS Express that uses Windows Authentication and was greeted with the following error:
Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Details:
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

Solution

Every time I bring up a new machine I always forget to update the IIS Express setting to fix this error and have to do a google search to figure out where the IIS Express configuration is stored. So I figured I should finally document the fix for it.
The error is caused by this section in the web.config
<system.webServer>
 <security>
  <authentication>
   <windowsAuthentication enabled="true" />
   <anonymousAuthentication enabled="false" />   
  </authentication>
 </security>
</system.webServer>
To fix this open up the IIS Express applicationhost.config. This file is stored at C:\Users[your user name]\Documents\IISExpress\config\applicationhost.config
Update for VS2015+: config file location is $(solutionDir).vs\config\applicationhost.config
Look for the following lines
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
Change those lines to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
Save the file and refresh your asp.net web page. It may take a moment to load as it load the new configurations into IIS Express.

Thanks to :
http://digitaldrummerj.me/iis-express-windows-authentication/