DisableCache in web.config not working on GoDaddy - caching

I recently put a basic site out on GoDaddy, and for obvious reasons, I don't want it caching the HTML files. JSON files and other resources are fine, but not the initial HTML files themselves.
This site was hand-coded in Notepad++; WordPress was not used.
On my local IIS server, the caching for HTML files was disabled without much trouble. This is the web.config file for the overall site:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="iisstart.htm" />
<remove value="index.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
</files>
</defaultDocument>
<caching>
<profiles>
<add extension=".html" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
The addelement under caching/profiles works just fine on my IIS server when testing locally. However it's been noticed that it is effectively getting ignored on GoDaddy / Plesk.
So my question is: What do you have to do to get GoDaddy / Plesk to go ahead and stop caching the HTML files?

Try to add below code in your web.config file:
<caching>
<add extension=".html" policy="DontCache" kernelCachePolicy="DontCache" />
</caching>
when you try to access site hard refresh the browser and check that is it working or not.
You could refer this link for more detail.

Related

Autogenerated web.config not accepted by IIS 10

I want to publish a entity framework core (.Net) to a IIS.
For this I publish the application in Visual Studio Community 2017. When I publish the application the web.config file will be auto generated as the following
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\basket.api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: ba174064-1719-4e47-a0c3-5e8cff312047-->
I go to my IIS 10
I post it into the default website. Into to the location "C:\inetpub\wwwroot".
I start the web site an access via the webbrowser localhost.
I get allways the following error message:
I check the web page of Microsoft of the error code 0x8007000d,it is basicly saying that the format of a XML Element is not correct. Which is impossible I check all the formating and also I let autogenerate by the Visual Studio when i publish the site. I tried everything and don't know what to do. I am very newbie in IIS stuff.

How do I set the environment in a Visual Studio generated publish profile

I have 2 publish profiles. I want to make one staging and one production. After browsing a bit I found out you could use the command line publish to set an environment variable: dotnet publish /p:Configuration=Release /p:EnvironmentName=Staging. However my publish profiles are generated by Visual Studio and I was wondering if I could set it in there?
Although I didn't tried this approach on .Net Core, I believe that It will work since It is the feature of VS Publish (msbuild).
you need to create web.config. Something like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="WebDAV" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
<aspNetCore requestTimeout="00:30:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
then you need to add Config Transform for these (see below)
For the config transformation you can check this github documentation: https://github.com/vijayrkn/webconfigtransform/blob/master/README.md
then you need to transform your publish profile as well.
web.$(publish-profile-name).config is going to be your web.config name. You need to change environment variables of the transformed web.configs respectively.

Configuration of ASP.Net Core

I have a web project that the front-end is Angular 5 and the back-end is ASP.NET Core. the front-end and back-end are in separated projects.
I have a host with Windows as OS and Plesk as control panel, the Document root folder is home and placed in Home directory
I publish my api to home/api directory but I get some errors about not started application(502), when I publish my api to home directory, I can not access my front-end files and I get page can’t be found error
here is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
Is there any way to publish the API on any folder? like home/api

Can't commit several files from Visual Studio project to subversion

Since a few weeks, I have some problems with Subversion. When I try to commit files from a Visual Studio 2017 project there are some files which I can't commit to my Visual SVN Server. To be precise all files in the project folder like *.cs, *.config, *.csproj, *.resx, ...
My setup:
Client: TortoiseSVN 1.9.7 on Windows10
Server: VisualSVN behind a IIS-ReverseProxy running on Windows Server 2012r2
The error I get when I try to commit for example a *.cs file:
Commit
D:\Test\branches\ScaraControl\ScaraControl\Form1.cs
D:\Test\branches\ScaraControl\ScaraControl\Form1.cs
Commit failed (details follow):
File 'D:\Test\branches\ScaraControl\ScaraControl\Form1.cs' is out of date
'/svn/Test/!svn/txr/5-9/branches/ScaraControl/ScaraControl/Form1.cs' path not found
You have to update your working copy first.
Updating the working copy is finishing successfully but doesn't fix the problem.
You can see my project in the picture below. For testing, I created a completely new and empty repository. As you can see the .vs, bin and obj folders are ignored with all the files inside of them, all other folders are committed to the server (without the files inside of them). In the second picture you can see that I can commit the *.sln file but no other file in the project folder.
For testing, I created an empty text file and renamed it to text.cs. Even this empty file cannot be committed to the Server with the same error message.
Due to the fact that this is happening to all Clients, it is more likely to be a problem on the Server side I guess but I have no idea what could cause this error. Unfortunately, the VisualSVN Server has no error logging or at least not the free version I'm using.
I would be very grateful for any tip I can get to solve this annoying problem.
Edit1: Problem is caused by the IIS Reverse-Proxy
After connecting via port 8443 directly to the VisualSVN server (bypassing the reverse proxy) everything is working again. So there must be a problem with the configuration of the URL Rewrite module. To be honest it took me quiet a long time to get it working somehow because my knowledge about all the settings is very limited.
This my Web.config with the settings for the URL Rewrite module. Maybe there is something not configured as it should be. If you need further information just ask.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true">
<match filterByTags="A, Form, Img" pattern="^http(s)?://svn.example.org:8443/(.*)" />
<action type="Rewrite" value="http{R:1}://svn.example.org/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://svn.example.org:8443/{R:1}" />
</rule>
</rules>
</rewrite>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="" roles="Users" />
<add accessType="Allow" users="*" />
<add accessType="Allow" users="?" />
</authorization>
</security>
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
<httpRedirect enabled="false" destination="https://svn.example.org" exactDestination="true" childOnly="true" />
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
I had the same issue.
The fails because IIS prohibits URL suffixes like .cs and .config
You can work around this by adding this to the web.config of the IIS proxy
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true" applyToWebDAV="true">
<clear />
</fileExtensions>
<verbs allowUnlisted="true" applyToWebDAV="true" />
<hiddenSegments applyToWebDAV="true">
<clear />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
Credits to this post IIS7 and ARR as reverse proxy for Subversion
I came across the same problem and am running a reverse proxy through IIS, so believe that has something to do with it.
VisualSVN is served up locally on https://localhost:8443 and I was attempting to use the reverse proxy to route from https://svn.mysite.com. This appears to work fine. You can even checkout a fresh copy of the repo and all files are downloaded. It's when you try and commit that you have problems - as you've identified, certain files fail to be found on the repo.
The only work around I have found (thanks to your question narrowing down the likely causes) was to add the port to the URL: https://svn.mysite.com:8443. This shouldn't be necessary as the reverse proxy should handle, so I'm guessing it's an issue with VisualSVN which may be fixed in a future update.

Only allow script access to a file iis7.5

I have a file (called 'log.html') on my iis7.5 server that I would like my PHP installation to be able to access and write to, but I do not want anybody to access the file directly, for example typing in 'http://computername/log.html' (I am on a LAN).
How can I prevent users from accessing it but allow php to see it?
When using the web.config file suggested below, I get this error:
You can use IIS URL Rewrite and create a Request Blocking Rule to prevent access over HTTP:
For example:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="BlockLogFile"
patternSyntax="Wildcard"
stopProcessing="true">
<match url="*" />
<conditions>
<add input="{URL}" pattern="/log.html" />
</conditions>
<action type="CustomResponse"
statusCode="403"
statusReason="Forbidden: Access is denied."
statusDescription="This is sekret!" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I think that I may have answered my own question! I still need to test it a bit more, and perhaps if it does not work completely then someone could correct me:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="cache-control" value="no-store, no-cache, must-revalidate, max-age=0" />
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence="log.html" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>
The cache control bit prevents the browser from caching anything that it returned.
Hope this helps somebody else! I am still very new to this, so you might be able to get around this.

Resources