Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Thursday, 3 November 2016

How to configure the app pool recycle time from batch file


Stick the following in a configure_app_pool.bat batch file and run...


cls
@echo off

set last_five_chars_of_computername=%COMPUTERNAME:~-5%
echo.Running on %last_five_chars_of_computername%

SET recyle_time=01:55:00
IF "%last_five_chars_of_computername%" EQU "BAP01" SET recyle_time=01:55:00
IF "%last_five_chars_of_computername%" EQU "BAP02" SET recyle_time=01:56:00
IF "%last_five_chars_of_computername%" EQU "BAP03" SET recyle_time=01:57:00

REM CHOICE /C 123 /N /M "Enter 1 for bap01, 2 for bap02 or 3 for bap03, or press Ctrl+C to cancel"

REM SET answer=%ERRORLEVEL%
REM IF %answer% EQU 1 SET recyle_time=01:55:00
REM IF %answer% EQU 2 SET recyle_time=01:56:00
REM IF %answer% EQU 3 SET recyle_time=01:57:00

echo setting apppool recycle time to %recyle_time%

set recycle_period=1.05:00:00
echo setting apppool recycle period to %recycle_period%

setlocal


set servers=Beacon@RRA
set servers=%servers:@=,%

for %%a in (%servers%) do (
  FOR /F "delims=," %%i in ('%systemroot%\system32\inetsrv\appcmd list apppool /name:"$=*%%a*" /text:name') do (
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo         Setting up app pool: "%%i"                       
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call:setFunc "%%i"
)
)

goto :eos

:eos
endlocal
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo         Please verify above configuration changes      
echo         Then press any key to exit      
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
pause
@echo on
goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:setFunc
echo.
echo ***** BEFORE ******
%systemroot%\system32\inetsrv\APPCMD list apppool /apppool.name:"%~1" /config
%systemroot%\system32\inetsrv\APPCMD set apppool /apppool.name:"%~1" /recycling.periodicRestart.time:%recycle_period%
%systemroot%\system32\inetsrv\APPCMD set apppool /apppool.name:"%~1" /+recycling.periodicRestart.schedule.[value='%recyle_time%']
%systemroot%\system32\inetsrv\APPCMD set config /section:applicationPools /[name='"%~1"'].recycling.logEventOnRecycle:Time,Schedule,Memory,IsapiUnhealthy,OnDemand,ConfigChange,PrivateMemory -commit:apphost
echo.
echo ***** AFTER ******
%systemroot%\system32\inetsrv\APPCMD list apppool /apppool.name:"%~1" /config

Wednesday, 22 April 2015

Catastrophic failure when attaching Visual Studio Debugger to IISExpress

Symptom: Unable to attach to the process. Catastrophic failure.
Resolution: Change project settings to enable edit and continue, then press F5 to start the web project in debug mode.
image
I also deleted my solution.suo file from the solutions directory as it was over 3MB! - more about that here -http://merrickchaffer.blogspot.co.uk/2012/02/visual-studio-hanging-running-slowly.html


Tuesday, 20 May 2014

Starting IISExpress from command line

start "" "C:\Program Files (x86)\IIS Express\iisexpress.exe"  /config:"%userprofile%\Documents\IISExpress\config\applicationhost.config"  /site:"RRA.Web.McMuffin" /apppool:"Clr4IntegratedAppPool"

P.S. One of the many benefits I've discovered in starting IISExpress in this way from the command line, is that you get fiddler type page visit logging output for each page request in the resulting console window..

image

Wednesday, 11 December 2013

Altering the HTTP response using Fiddler

Should you ever have the need to change the http response to a web server, then please note in the latest version of Fiddler it's actually possible to do this without having to hack the CustomRules.js file that the Fiddler training videos and documentation tell you about.

You can simply set up an AutoResponder tab rule as follows

1. Stick a file in %userprofile%\Documents\Fiddler2\Captures\Responses folder

2. Highlight the request you want to set up a rule for

3. Got to the AutoResponder tab and check Enable automatic responses and unmagtched requests passthrough

4. Click Add rule

5. In the dropdown list control at the bottom, select the file that you dropped in the folder in step 1 above.

6. Hit the save button

7. Clear the Cache

clip_image001

Now next time you request that resource, the version you have saved on disk will be downloaded instead. You can check this by looking in the IE cache folder %userprofile

%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files

More detail about request and response breakpoints in fiddler here… (this is very useful should you wish to change the request going to the server in the first place as well)…

http://www.youtube.com/watch?v=8bo5kXMAcV0&list=PLvmaC-XMqeBbw72l2G7FG7CntDTErjbHc&index=2

P.S. For more powerful / permanent debugging solution you can just alter the fiddler customrules.js as follows

static function OnBeforeResponse(oSession: Session) {

        if (m_Hide304s && oSession.responseCode == 304) {

            oSession["ui-hide"] = "true";

        }

if (oSession.uriContains("Name=ViewerScript")) {

                                                oSession["x-replywithfile"]="Reserved.ReportViewerWebControl.axd";

                                }

    }

Thursday, 17 January 2013

Project Silk for all your HTML web application needs

A colleague of mine pointed out this white paper article that Microsoft have kindly put together, which appears to be a full overview on how to construct a web site in this day an age.

"Guidance for building cross-browser web applications with a focus on client-side interactivity. These applications take advantage of the latest web standards like HTML5, CSS3 and ECMAScript 5 along with modern web technologies such as jQuery, Internet Explorer 9, and ASP.NET MVC3"

http://silk.codeplex.com/

You can also download it all in pdf format from the following link

http://www.microsoft.com/en-us/download/details.aspx?id=27290

Tuesday, 3 July 2012

How to set the physical path of a virtual directory from the command line using appcmd.exe

 

>\Windows\System32\inetsrv\appcmd.exe set vdir "Default Web Site/MyAppName/" -physicalPath:"C:\MyAppPath"

For more information relating to appcmd.exe and it's various usages, see this link here...

http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/

Also to discover which app pool workerprocess is which you can use the following command

%systemroot%\system32\inetsrv\appcmd.exe list WP

or just look at your task manager with the command line column expanded for the w3wp.exe process

 

image

Monday, 25 June 2012

Using Apache benchmark to load test your web site

You can download the apache web server, then simply look inside the zip file for ab.exe.

E.g. to load test your site with 10 concurrent requests use the following command line...

>ab.exe -n 10 -c 10 http://localhost/mywebsite

For more information see 8.15mins into this video link...

http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2287

Monday, 6 June 2011

Increasing WCF performance

Last week a colleague of mine discovered that for each WCF call, there are actually 2 round trips between client and the server going on using wireshark. This can especially be bad where the network latency on your site is also high, as for each request for data, there is the first call to authenticate the user, which then needs a reply back, then the actual call to get the data, which of course comes back as well, hence 4 x the network latency.

There are some solutions to this e.g. using a Secure Token Service, see http://msdn.microsoft.com/en-us/library/ee748498.aspx for more detail.

There is however an alternative to this which could provide better performance from http://www.noemax.com/

Thursday, 26 May 2011

Debugging IIS w3wp.exe process

When debugging  IIS and taking a while to look at your code, you may sometimes get this message

clip_image002

To fix this simply switch off the ping enabled setting in your IIS, application pool, advanced settings

clip_image004

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...