Need some help combining these if you can, please.
One is to allow .html and .htm files to act like .asp files for some includes and the other is for custom 404 pages.
I've tried all sorts of variations, but everything apart from using the files separately gives me a '500 - Internal Server Error' message.
web.config 1:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
web.config 2:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>
This should work. Check parent web.config files and look for issues cause by inheritance.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>
Related
When I publish my .net core app to azure, the web.config seems to revert to something else and I can't figure out why.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000" maxUrl="102410" maxQueryString="204810" />
</requestFiltering>
</security>
<applicationInitialization>
<add initializationPage="/" />
</applicationInitialization>
</system.webServer>
</configuration>
But what arrives on the server is this:
<?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=".\App.UI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
The security and appinitialization sections completely disappear. What's going on here?
Downloaded a free startup template and got a zip archive with the whole solution.
When unzipping the archive on windows I got a message asking whether to overwrite existing web.config file.
And indeed there are two web.config files below /src/myapp.Web.Host/.
The two file names differ in upper/lower case of the first letter.
One is named Web.config and the other web.config and the content differs.
Which one shall I use?
Options used:
ASP.NET Core 2.x
Target Framework: .NET Core (Cross Platform)
SPA with Angular
Include login, ...
One Solution
Until the issue fixes, you can use this web.config content...I tried, works perfectly.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!-- ASPNET CORE SETTINS -->
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore
processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"
startupTimeLimit="3600"
requestTimeout="23:00:00" />
<!-- REMOVE INFO LEAK HEADERS -->
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<!-- MIME TYPES -->
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<mimeMap fileExtension="woff2" mimeType="application/font-woff" />
</staticContent>
<!-- IIS URL Rewrite for Angular routes -->
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
https://github.com/aspnetboilerplate/aspnetboilerplate/files/2149283/Web.config.zip
I want to deploy my jar on microsoft azure but it shows me an internal server error. the jar works on my pc fine, i added the following web.config file to my wwwroot:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar ";%HOME%\site\wwwroot\myjar.jar";">
</httpPlatform>
</system.webServer>
</configuration>
Unfortunately it does not work... I want to deploy it on a webApp in azure
It was a non-well formated xml file... now it works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar %HOME%\site\wwwroot\myjar.jar" >
</httpPlatform>
</system.webServer>
</configuration>
All I want to do is 301 redirect from old URLs to new URLs:
from /xx/yy/somefile.html to /xx/yy/somefile.aspx
some examples below:
add key="/products/DSD-72B-SP-summary.html" value="/products/DSD-72B-SP-summary.aspx"
add key="/products/DSD-72B-SP-detail" value="/products/DSD-72B-SP-detail.aspx"
add key="index.html" value="default.aspx"
add key="/product-selector.html" value="/products.aspx"
That is all but it doesn't seem to want to work in IIS 7.5 with URL rewrite 2.0.
I have tried at least 10-20 different rules, and rewrite map formats without any luck.
In fact I have done this so many times I have had to wipe the rules and maps from IIS and totally recopy a web.config file from a backup to unscrew what I screwed with to try and make it work.
All I need is a simple rule that tells IIS that if it gets a request for a *.html file to display the *.aspx file that replaced the html file.
<?xml version="1.0" encoding="UTF-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
</CipherData>
</EncryptedData>
</appSettings>
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
</CipherData>
</EncryptedData>
</connectionStrings>
<system.web>
<customErrors mode="On" defaultRedirect="404-NotFound.aspx">
<error statusCode="404" redirect="404-NotFound.aspx" />
<!--<error statusCode="403" redirect=""/>-->
</customErrors>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<!--<codeSubDirectories>
<add directoryName="CSharp"/>
<add directoryName="VB"/>
</codeSubDirectories>-->
</compilation>
<authentication mode="Forms">
</authentication>
<membership>
<providers>
<clear />
</providers>
</membership>
<profile>
<providers>
<clear />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
<defaultDocument>
<files>
</files>
</defaultDocument>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404-NotFound.aspx" responseMode="ExecuteURL" />
</httpErrors>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="WWW Server" areas="Rewrite" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="200-500" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>
Make sure you clear your cache too. Sometimes you can update a server rule but your browser will continue to show the old page.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Vanity URL" enabled="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{MAPNAME:{PATH_INFO}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MAPNAME">
<add key="/products/DSD-72B-SP-summary.html" value="/products/DSD-72B-SP-summary.aspx" />
</rewriteMap>
</rewrite>
</system.webServer>
</configuration>
The above code it taking directly from my website with minor name changes for generality and added in your page. Try to remove other rules and isolate the issue.
I'm trying to have a custom error page working on Azure for all HTTP Errors.
On my dev machine everything is working fine, on Windows Azure it works for HTTP404 but I still have a YSOD for HTTP400.
Here is what I have in my web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<httpErrors errorMode="Custom" existingResponse="PassThrough">
<clear />
<error statusCode="400" path="~/Error" responseMode="ExecuteURL" />
<error statusCode="401" path="~/Error" responseMode="ExecuteURL" />
<error statusCode="403" path="~/Error" responseMode="ExecuteURL" />
<error statusCode="404" path="~/Error" responseMode="ExecuteURL" />
<error statusCode="500" path="~/Error" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On" defaultRedirect="~/Error" />
.....
</system.web>
Any idea of where to look to solve that?
Thanks in advance