Edit HTTP response headers for an application in IIS 7 - iis-7

I have a set of applications running in my IIS Server 7.0. I need to "Expire Web Content" of one of those applications through command line. Running appcmd.exe works, but it changes this configuration for all the applications in IIS. Is there a way to do this for a single application?
This is the command which I ran.
appcmd.exe set config /section:staticContent /clientCache.cacheControlMode:DisableCache
Thanks.

Use the following command, just replace "SITENAME" with your site id.
appcmd.exe set config "SITENAME" /section:staticContent /clientCache.cacheControlMode:DisableCache

Related

Custom IIS access logging on Azure

I would like to exclude user IP field in IIS access logs for a ASP.NET service hosted on Azure. Is there a way to achieve this? I'm using WAD to collect logs into a blob storage.
You will want to run an elevated Azure role startup task (see http://blogs.msdn.com/b/avkashchauhan/archive/2011/03/17/using-startup-task-in-windows-azure-detailed-summary.aspx) and run the following command to remove ClientIP field from logs:
%windir%\system32\inetsrv\appcmd set config -section:sites -siteDefaults.logfile.logExtFileFlags:Date,Time,UserName,ServerIP,Method,UriStem,UriQuery,TimeTaken,HttpStatus,Win32Status,ServerPort,UserAgent,HttpSubStatus,Referer
In the above command line "ClientIp" is removed which should remove the user IP field from the logs.
To add to BilalAlam's answer (though this doesn't directly answer the question)
His example will change logging for all sites
appcmd set config -section:sites -siteDefaults.logfile.logExtFileFlags:Date,Time,UserName,ServerIP,Method,UriStem,UriQuery,TimeTaken,HttpStatus,Win32Status,ServerPort,UserAgent,HttpSubStatus,Referer
Here is how to change logging for a single site
appcmd.exe set config -section:sites -"[name='ExampleSite'].logfile.logExtFileFlags:Date,Time,UserName,ServerIP,Method,UriStem,UriQuery,TimeTaken,HttpStatus,Win32Status,BytesSent,BytesRecv,ServerPort,UserAgent,Cookie,HttpSubStatus,Referer"����
If you want to make the change at the application host config file (instead of the web.config file), add /commit:apphost to the end of the command
appcmd.exe set config -section:sites -"[name='ExampleSite'].logfile.logExtFileFlags:Date,Time,UserName,ServerIP,Method,UriStem,UriQuery,TimeTaken,HttpStatus,Win32Status,BytesSent,BytesRecv,ServerPort,UserAgent,Cookie,HttpSubStatus,Referer" /commit:apphost

Deploying WCF webservice to IIS

I'm trying to deploy a wcf web service to IIS 7.5. Is there anything special I need to do in order to make this work. I keep getting 404 error when I try and run the web service. I can't seem to pull up the wsdl file either.
These are the steps I've taken
Right-clicked on web service project and published to local folder
Copied contents of publish to IIS server
Setup a new website that points to folder with webservice files
set binding to match web.config binding (port #)
Is there anything I missed or overlooked. Shouldn't I be able to run that web service from IIS and load up the wsdl file directly on the server. When I test in visual studio, it handles the loading of that host program.
Apparently you have to load the .svc file path which I was not doing.
Just to expand on this a little, since this question got me started but there were a couple of extra steps I had to take:
In VS2012 right click on the web service project and select Publish
Publish to file system by selecting a directory to publish to
Copy the folder contents into a folder on the server
In IIS create a new website, its physical path being where you just copied the published contents to.
Set its app pool appropriately (probably .NET 4.0)
The binding port should be the same as in the web.config as should the name. So if you've been working locally and your web.config reads "http://localhost:12345/MyService" then hostname is "localhost" and the port is 12345
You can then browse to the webservice by right clicking on the website in IIS -> Manage Website -> Browse. Click on your service name.

Set a default user/password when in localhost

Is there a way to set a default user/password in web.config of a ASP.NET application only while it's running in localhost?
I've done some research and found some tags like "credentials" but I ended up with no results.
Thanks :D
If you take advantage of the publish option and the web.release.config file, you can have the credentials in the root config, and write a transform to remote it from the web config when published in release mode.

using appcmd to turn off SSL in IIS 7.0

Appcmd will turn off SSL in IIS 7.0 following this command line from microsoft:
appcmd set config " Default Web Site "/section: access /sslFlags:None /commit:APPHOST
I am replacing "Default Web Site" with our own. The command returns with a statement that it succeeded. However, when looking at the SSL setting in IIS Mgr, it is still enabled, and the web page is also complaining of the security issue. I can turn it off via IIS Mgr, but for our needs, it needs to be done at the command line.
There doesn't seem to be any other security issue regarding changing the setting that I have found. I have tried stopping the site, then applying the appcmd above, starting the site, and same issue.
Any suggestions?
Windows Server 2007
The command you have above (minus it's spacing problems) works perfectly well for me. i've just tried it on W7 and IIS7.5
appcmd set config "Default Web Site" /section:access /sslFlags:None /commit:APPHOST
Are you running the command prompt as administrator?
To be clear, that will not turn off SSL, that will just tell IIS that it is ok to allow customers not to use SSL, but the SSL endpoint could very well be there.
If your goal is to remove SSL altogether then you need to also remove the binding from the site that points to 443 something like:
appcmd.exe set config sites /-"[name='YourSite'].bindings.[protocol='https',bindingInformation='*:443:']" /commit:apphost
Also, be aware that this will still leave the SSL binding in http.sys so you will need to do also a "netsh http del sslcert 'endpoint in here' "

Can an ASP.NET web app run without web.config

Can my asp.net web application run without a web.config?
For argument's sake lets say that I'm not connecting to a Database or explicitly reading any
configuration information .
I have tried it out and I'm able to run a web app successfully in VS 2008 without a web.config.
This brings me to the question as to how are authentication and session modes configured now ?
The machine.config and the root web.config files ( in the framework folder) do not have any authentication/session modes configured explicitly .
Any ideas ?
Thanks.
yes we can run asp.net application without web.config file,if u r not configure any settings in web.config file then it will take machine.config file for default configurtaons.This config file will automatically installed when your application getting executed.
Because all the configuration settings will be available under MACHINE.CONFIG file by default these settings will be applied to all asp.net applications.
You'd have to read the documentation to see the defaults, which for authentication is probably windows, and session mode would be in process.
Yes, you will be able to run an ASP.NET application without a WEB.CONFIG file in its root folder.
If the application doesn’t find a WEB.CONFIG file in its root folder, then it will take MACHINE.CONFIG file for default configurations. But you will not be able to debug the application as debugging is turned off by default in MACHINE.CONFIG file.
Find more information about machine.config files over here

Resources