I have read through answers here and still stuck: IIS7 Cache-Control
I have the following web.config.xml file in the root directory of my website:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
</staticContent>
</system.webServer>
</configuration>
The purpose of this web.config file is to pass the Google PageSpeed Insight 'leverage browser caching' test. I am using Windows Plesk hosting, and therefore cannot use a .htaccess file for this.
No matter how I try and format the contents of the web.config file, Google does not seem to recognise any form of browser caching is occurring. I am not sure if it is just Google, or if it means that the images and other static resources on my page are being cached or not. Is there an easy way to check this?
Can anyone see any issues with my web.config.xml contents that might be causing the issue? Or is there anything else I need to do with it other than stick it in the root directory of my site?
The file name should be web.config and not web.config.xml
*.config is already a xml type of file
Related
I want to add re-write rules to my Azure app service, but if I even try create a web.config with a simple rewrite as shown below, the site returns an HTTP 500.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="test" />
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
What I did is create the web.config from scratch and FTP it into the wwwroot folder for the app service which is where I Ftp'd the rest of my web site files.
I have seen an old conversation about web.config files in Azure, but I'm not even sure if this is in regards to Azure app service - and things change so quickly in Azure that I thought I should ask separately anyways.
I have also seen this link about using web.config transforms. Maybe this is required?
This other link seems to indicate that updating web.config is possible, but their example results in an HTTP 500 for me as well.
I've looked through configuration options in the Azure portal for my app service and nothing seems to jump out at me.
>>”This other link seems to indicate that updating web.config is possible”
Yes, we could update the configuration of Web App by updating Web.config file directly. You could upload a new version of configuration file to wwwroot folder by FTP/WebDeply or any other ways provided by Kudu. Another easy way to edit files in wwwroot folder is using the App Service Editor, you could use it to edit the configuration file.
I can’t reproduce your problem on my side. Following are what I done.
Create a Web App using a Web App Plan with “Shared” SKU.
Create 2 file, a index.html file and a Web.config file. The content in Web.config is same as yours.
Upload these files to wwwroot folder of my web app using FTP.
Open a web browser and input a URL like this “http: // xxx.azurewebsites.net/test”. The web server will return the content of index.html. It proves that the rewrite is working fine.
>>”but their example results in an HTTP 500 for me as well.”
Firstly, please mark sure whether the rewrite is working fine or not. I suggest you view the index.html page directly and check whether the error code(500) comes from index.html page.
Sometimes we provide the wrong syntax for rewrite rule, it will return 500 (URL Rewrite Module Error). Have you enabled Detailed Error Logging and Web Server Logging for your web app. If yes, you could view the detail error message to get more useful information. For how to enable and view diagnostics logging, link below is for your reference.
Enable diagnostics logging for web apps in Azure App Service
When i try to download iso file, it results in 404 page not found. The link in this instance is like:
http://www.domain.com/virtualDir/filename.iso
virtualDir points to a location on our file servers.
I don't want to read the binary array and then push it out as download since it is almost 600mb. I want the browser to handle this just like exes and zips.
What is the best way to handle this?
I would imagine it is because IIS doesn't serve unknown file extensions. You need to add the MIME type to the overall IIS settings, or the web.config. As you asked for in the comment, I'd probably recommend placing it in the web.config since it doesn't require additional configuration from a sysadmin and everything is in one place.
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".iso" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
I have an MVC3 application with a couple of areas and a portable area as well (using MVCContrib)
Normally, I keep all my content files under ~/Content and my scripts under ~/Scripts.
However, I am building a fairly complex webclient to another service on my site and I want to organize those javascript and image files (LOTS of image files and resources) under the Area's folder structure, which looks something like this, under ~/Areas/WebClient
Content
css
fonts
images
js
Controllers
Models
Views
I have a resource aggregator controller (one of my portable areas) that is able to reach into the CSS/JS folders just fine to provide that content. However, the CSS files reference the images/fonts folders directly and all of those links show up broken. I have double and triple checked the paths and made sure everything was right but I still get 404 errors.
As far as I know MVC3 is supposed to ignore routing so long as there's a static file there. Also, as far as I know, only the App_* folders enjoy special protection. What am I missing? I'd rather not mix in my images and resources with my main application if I can at all avoid it.
As an example: http://localhost/Areas/WebClient/Content/images/knownimage.png will not work, but should, as it exists!
So after some sleep and, more importantly, stepping away from the problem I remembered that MVC does in fact offer you protection from people downloading views directly, which led me to remember the Web.config file required in the Areas folder. Sure enough, there's an httphandler that basically sends all requests to the FileNotFound handler.
All I had to do was drop a web.config file in the content folder I wanted to expose with the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
</handlers>
</system.webServer>
</configuration>
Problem solved.
I have a php Facebook application which I have uploaded in a Microsoft server. When I run the application i get this error. Does anybody know the cause of this ?
405 - HTTP verb used to access this page is not allowed. The page you
are looking for cannot be displayed because an invalid method (HTTP
verb) was used to attempt access.
Even if you are using IIS or apache, in my guess you are using static html page as a landing page, and by default the web server doesn't allow POST or GET verb on .html page, facebook calls your page via POST/GET verb
the solution would be to rename the page into .php or .aspx
and you should be good to go :)
In the Facebook app control panel make sure you have a forward slash on the end of any specified URL if you are only specifying a folder name
i.e.
Page Tab URL: http://mypagetabserver.com/custom_tab/
you can add these lines to the web.config:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
It means litraly that, your trying to use the wrong http verb when accessing some http content. A lot of content on webservices you need to use a POST to consume. I suspect your trying to access the facebook API using the wrong http verb.
I fixed mine by adding these lines on my IIS webconfig.
<httpErrors>
<remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" prefixLanguageFilePath="" path="/my-page.htm" responseMode="ExecuteURL" />
</httpErrors>
I've been pulling my hair out over this one for a couple of hours also. fakeartist appears correct though - I changed the file extension from .htm to .php and I can now see my page in Facebook! It also works if you change the extension to .aspx - perhaps it just needs to be a server side extension (I've not tried with .jsp).
Try renaming the default file. In my case, a recent move to IIS7.5 gave the 405 error. I changed index.aspx to default.aspx and it worked immediately for me.
In my case, IIS was fine but.. uh.. all the files in the folder except web.config had been deleted (a manual deployment half-done on a test site).
I got this error when I was using jquery and lib was not present in the given path, once jquery lib is added back error was gone.
[File name - calculate.html]
I had this err on the host too (my project was .net core2.1 webapi )
please add this code in web config in host :
<modules>
<remove name="WebDAVModule" />
</modules>
this site : http://medisra.sideradesign.com
it is rendering in IE7 document mode by default.
Is this due to a CSS or HTML validation error? how can I identify what's causing it?
thanks
Here's all the places I can think of where the header could be coming from.
Considering your comment:
I have other subdomains on the same
server and the sites render in
standards mode.
It's unlikely to be defined in Apache's httpd.conf or similar.
Have you made 100% sure there are no other .htaccess files or other configuration files which could be introducing it?
Is your PHP code outputting the header? It would look like this in PHP:
header('X-UA-Compatible: IE=EmulateIE7');
Could it perhaps be the fault of a Wordpress plugin?
You could use a utility to search in every single file of the website for the string "EmulateIE7".
If you still can't find it after following through those ideas, I'm afraid I can't think of anything else.
This is a good reference about defining document compatibility mode.
This will render all pages on the site in IE7
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Check in the source of that page if the head contains the following meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
If it does, that's why it renders the page like IE7 by default.