IIS: How to enable httpcompression on site level? - azure-cloud-services

In the Azure cloud service, we have start up task to enable httpcompression at the server level.
%appcmd% set config -section:system.webServer/serverRuntime /frequentHitThreshold:"1"
%appcmd% set config -section:system.webServer/urlCompression /doDynamicCompression:"True"
%appcmd% set config -section:system.webServer/httpCompression /-"dynamicTypes.[mimeType='text/css']"
%appcmd% set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='text/css',enabled='True']"
Then in the web.config, we do this to enable httpcompression at site level:
<urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" doStaticCompression="true" />
This does not work. In IIS Manager, I can see the site level has httpcompression enabled, but the response is not compressed.
However, if I set everything to false in web.config, then manually enable the settings in IIS Manager, it then works!
Any thoughts why that happens? This needs to be automated, so even though manually setting it works, it isn't a solution for me.
Thanks!!

Forgot to respond back with my finding - turns out I needed to remove the httpCompression and urlCompression settings in web.config , then everything just worked. Feels like an IIS bug.

Related

Getting error after publishing my project into Azure App-Aplication (Web Hosting)

I tried several times to publish my website from Visual Studio 2019 to the Azure server but I getting errors.
I have an MVC-CORE 3.0 project which works fine using IIS EXPRESS (localhost).
In my web-application, there is a login page (home page), which is the first view. It perfectly works both on Azure and the localhost.
But once I using the published website and log in to my account (=move to the next view), I got this error:
*The login process works great using localhost
*I already published my app 2 months ago and it perfectly worked!
This error appeared just after republishing (private needs).
Please HELP ME !!!
I think you should try these way to solve you issues.
According to your describe, you can open you site correctly. But when you do other operations, the error occured. Here are my advice,
Tips 1, check your web.config file ,make sure you dbConnection is correct. Pls pay attention to Connection strings in portal.And the priority on the portal is higher than that in the web.config.
Tips 2, check your web.config file ,modify the config, like the post. Add settings like below,
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
</configuration>
If my advices don't work, you can try to solve the problem by Monika Reddy-MSFT's way.
Update
If you can't open you site correctly, pls check Stack settings in portal.
And next time when you republish your apps, you can backup publish file first in order to restore previous version. Or you can publish your app in slot, if it works fine then you can swap it.
Have you tried to set the environment variable inside the web app on Azure?
If not, please try this:
Open the Application Settings blade --> Scroll Down to -->"Application Settings" --> add the "ASPNETCORE_ENVIRONMENT" and "Development".
Also please take a look at this doc for more reference.

cannot load nuget feed in visual studio

I am getting the following error when I try to load nget:
Unable to load the service index for source
https://api.nuget.org/v3/index.json. The ServicePointManager does
not support proxies with the https scheme.
Also, in Linqpad, I am getting a similar error:
ServicePointManager does not support proxies with the https scheme
Does anyone have any solutions for this? I found this post, but that solution, clearing the temp folders, did not fix my problem. Please help! Thanks!
The ServicePointManager does not support proxies with the https scheme.
Since you have proxy configured in the web.config, you may need to pay attention to the syntax of proxy.
You will also get this error if you set something like this in your web.config file: proxyAddress="127.0.0.1:8888"
You need list the scheme like this: proxyAddress="http://127.0.0.1:8888" (Add http://). The only scheme that is recognized by this class is http.
Besides, since you have proxy configured in you machine, NuGet will fail to access to the server. You should add proxy settings into Nuget.Config file, goto %AppData%\NuGet\NuGet.config, add below settings:
<config>
<add key="HTTP_PROXY" value="http://127.0.0.1:8888" />
</config>
You can refer to the NuGet Proxy Settings for more detailed info.
Found the problem! I basically just needed to remove the proxy setting from nuget and it looks like the command line was the best place for it. Thanks to #Leo-MSFT for the helpful suggestions.
Update: [8/8/2017] The problem has reemerged but this time, my fix won't save me since its still applied. I've checked all 3 spots for the nuget proxy settings and its still not working. I have no idea what's wrong now. Grrrr!!!!
Update: [8/8/2017, part deux] Found it! I had fiddler set in the machine.config as well, so make sure to check that if you are prone to forgetfulness like I am.
<system.net>
<!-- <defaultProxy
enabled = "true"
useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>-->
</system.net>
Fiddler was the culprit in my case too. I had to comment proxy settings from machine.config
residing in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config.
<system.net>
<!-- <defaultProxy enabled="true" useDefaultCredentials="true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false"/>
</defaultProxy> -->
</system.net>

"HTTP Error 403.14 - Forbidden" error when running the webapp

What is the reason for the error page I get when I run my webapp in Visual Studio. The URL is http://localhost:5000/
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Reason: http://localhost:5000 refers to the root of the webserver. So, for the above request, it tries to read the root folder of the server. However, IIS (express) by default doesn't allow you to view the file system. Therefore it shows above error.
Most probably you don't need to access the root of the server, instead you might need to access your webapp (ex: http://localhost:5000/myapp).
However, if you know exactly what you are doing then you can enable IIS to show the root directory (file system) using the following config in the Web.config of your application
Important: Below config should not be activated in a production or any
publicly reachable environment which is obviously a high critical
security issue.
<system.webServer>
<directoryBrowse enabled="true" />
<modules runAllManagedModulesForAllRequests="true"></modules>
</system.webServer>
Two things are usually the issue when I get this error:
1st: I never defined a standard document and changed it at some point - therefore the standard document that is automatically defined by the IIS in this case, doesn't exist
2nd: I didn't enable index search
You might want to try this. You can change those settings in the IIS settings directly.

Why am I getting error 500.0 in when using IIS Express (significant debug info included)

I created a blank MVC 3 application on VS2010 SP1, and set the app to use IIS Express. When I debug, I get error 500.0 (0x80070585)
I am able to succesfuly run the app using the VS dev server
I have set the app directory to Full Permissions for Everyone, just to eliminate all possibility of security issues. I have further verified that IIS express is able to hit the web.config by confirming it using SysInternals ProcMon. ProcMon does not show the IISExpress process attempting to read from any other files in my application directory.
I have followed the suggestions in the following question, but it does not give me any better information. HTTP 500 Internal Error - IIS websites
No logs are generated in the IISExpress directory in either the Logs or TraceLogs directory, but a log is created in Temp, however it is not very useful.
Successfully registered URL "http://localhost:62017/" for site "MvcApplication1" application "/"
Registration completed for site "MvcApplication1"
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0
There are no messages I am able to find in the Event Viewer
**Updates : **
Disabled firewall, no change
Ran IISExpress via command line, no change
I had the same issue last week, the app running perfect in dev web server from VS Studio. But in IISExpress anytime HTTP Error 500. My solution on this time was:
close VS Studio - solution set with IISExpress
got to: /Document/IISExpress/config/ in your profile
rename or delete applicationhost.config
open your solution in VS Studio
a Dialog will fire up from IISExpress - this will set a fresh config.
try to run your web app
You may have some mime code in the Web.Config file like this:
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
if so, you should remove mimeMap before adding like this:
.
..
...
....
</system.web>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
....
...
..
.
This may be related to a conflict between the IIS Express applicationhost.config and your web.config.
A mimeType was added to my local web.config that was already present in the applicationhost.config and IIS Express started serving many 500 errors.
You may also notice this error in your Windows Event Log, "The directory specified for caching compressed content is invalid. Static compression is being disabled."
More info: http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/
I removed the mimeTypes from the web.config and the issue was resolved.
applicationhost.config location: C:\Users\[User]\Documents\IISExpress\config
reinstalling iis express appears to have resolved this problem
Are you using any PLINQ(.AsParallel) or Parallel.For or similar methods? I've found that the AggregateExceptions they throw aren't handled well by MVC (In my case, I got a blank 500 page and nothing in Logs/Event logs).
I identified the problem by paying attention to the "First Chance" exceptions which are logged in the Debug output window in VS. Try running the site, waiting for it to error, clearing the Debug window and the reloading the page. Do you see anything useful?
There might be a problem with your config files, specifically web.config and applicationhost.config.
The only way I know how to diagnose this, is to publish a build to regular IIS, and in IIS Manager check the "Error Pages" module of the Site. If it is indeed an issue with those config files, you'll get a popup here with something along the lines: "Cannot add duplicate entry of type …". Google accordingly.
If the "duplicate entry" is of type "error", you can try adding the following element below httpErrors:
<remove statusCode="404"/>
That is, assuming you have an Error element below the HttpErrors with statusCode 404. (I had once.)
In my case the issue was caused by using windows authentication + firefox + wrong domain login with insufficient permissions.
Details:
My dev machine is using windows domain "domA", the application will run in an environment accepting logins from domain "domA" and "domB". While on the webserver both will work, on my dev machine only my account in "domA" has sufficient permissions to access all files of the application. In IE "domA" is used by default while in FF I get a login dialog where I did login with my account from "domB".
Confusing issue I know, but maybe there is someone else having the same situation. At least it will help me the next time I run into it. :)
Just in case catches someone else out, I had similar error but the issue was I had updated my web.config and there was an extra ">" character where it should be.. so malformed web.config file can cause the same behaviour.

HttpWebRequest slow fix by setting Proxy to null

I rectified my HttpWebRequest initial calls being slow by using the suggestion mentioned at
Why is this WebRequest code slow?
One of the suggestions mentioned to set the Proxy to null and things will speed up.
I have done this and it worked.
However Im concerned about the impact of this when I deploy this at some client sites....
It may be at some client sites that have configured their domain to go through a proxy to reach the server in which I am making my HttpWebRequest to.
Will setting Proxy properly to null impinge upon this?
Thanks
I wondered the same thing too. I was not able to find any answer to this question, though.
However, I did find that you can accomplish the same effect as hard coding httprequest.Proxy = null by adding a setting to the application config file:
<system.net>
<defaultProxy>
<proxy bypassonlocal="true" usesystemdefault="false" />
</defaultProxy>
</system.net>
My thinking is that if I ever find myself at a customer site where I need to change the automatic proxy detection I can remove the settings from the config file.
I found this fix at the following site:
http://weblog.west-wind.com/posts/2005/Dec/14/Slow-Http-client-calls-from-ASPNET-20-Make-sure-you-check-your-Proxy-Settings

Resources