Archive
HowTo: URL rewrite to redirect HTTP to HTTPS for non-local address
Below is an answer on how to redirect from HTTP to HTTPS using the URL Rewrite module for IIS, but ignoring local addresses used when debugging one’s app. Just contributed at https://stackoverflow.com/a/75898224/903783.
Needed it for an ASP.net MVC app I’m maintaining, since due to updated policy that the authenticating organisation had decided for the SSO (Apereo CAS) configuration, we couldn’t redirect anymore back to a non-HTTPs URL (had the user used plain HTTP to access our app that is), after signing in succesfully via the SSO.
Combined URL Rewrite based answers from How to redirect HTTP to HTTPS in MVC application (IIS7.5) and from the question’s page on StackOverflow, and added "127.0.0.1" apart from “localhost” for the ignored sites.
Note that the URL Rewrite approach is by far the simplest one to add and should kick in at the web server level before the web app has any chance to process the request.
I also see {REQUEST_URI} being used instead of {R:1} and pattern="^OFF$" instead of pattern="off".
At pattern added the ignoreCase="true" too, though it might be the default (same goes for enabled="true" for the rule, handy to have there if you want to turn some rule off when debugging some rule chain)
However, wondering based on https://serverfault.com/questions/224039/iis-url-rewrite-http-to-https-with-port/418530#418530 if one needs to use SERVER_NAME instead of HTTP_HOST in the pattern if non-default ports are used and specify the port in the Redirect url too
<system.webServer>
<!-- … -->
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect (excluding localhost)" enabled="true"
stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
<add input="{HTTP_HOST}" pattern="127.0.0.1" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
<!-- … -->
</system.webServer>
HowTo: Tell IE to use compatibility mode without editing your web pages
one reads:
We are using Telerik’s rich text editor (RadEditor), and it seems that RadEditor has specific behaviour regarding insertion of break tags.
To circumvent this issue please try to add host header in ISS 7 (website level):
Name = "X-UA-Compatible"
Value = "IE=EmulateIE10"Or, you can insert Html Meta tag on a PreRender event (of Page that uses RadEditor):
HtmlMeta meta =
new
HtmlMeta();
meta.Attributes.Add(
"http-equiv"
,
"X-UA-Compatible"
);
meta.Attributes.Add(
"content"
,
"IE=EmulateIE10"
);
Page.Header.Controls.Add(meta);
This is a very handy trick, one can open up a website at IIS console and open HTTP Response Headers node and then add the Name / Value pair X-UA-Compatible / IE=EmulateIE10 to force say Internet Explorer 11 to behave like Internet Explorer 10
To confirm it works, press F12 to show developer tools in IE11 and see at the right that it says “IE10” instead of “Edge” at the HTML engine selection dropdown list (compatibility mode).
Set default document for IIS via web.config at Silverlight Web project
When you tell the Visual Studio IDE to generate a web project (instead of just using an autogenerated page) for a Silverlight project, it creates a project named SilverlightAppName.Web with a SilverlightAppNameTestPage.aspx (ASP.net) and an SilverlightAppNameTestPage.html. Either one can be served from a web server (obviously the .aspx one from IIS or any web server that supports ASP.net at the server-side) to run the Silverlight app in the browser, or for debugging from within Visual Studio (with the included test web server [Cassini] or IIS).
Note that at that Web project’s Properties, there’s a tab Silverlight applications, where Silverlight apps hosted by that Web project are listed. If you add more there, Visual Studio will generate respective pages for them, in the pattern mentioned above.
By right clicking one of those two pages you can select “Set as Start Page” to set the default page that “Start” or “Start without debugging” uses. However that setting isn’t replicated to the web.config file automatically so that after publishing (by right clicking the web project and selecting “Publish”) that Web project to say a subfolder under “wwwroot” of IIS (or deeper in the web folders hierarchy).
If it was doing so, you would be able to just visit that folder and have IIS (or any other web server that supports the web.config scheme) serve the wanted page as the default document (instead of showing a can’t browse folder error or displaying the folder contents if Directory Browsing has been enabled at IIS console for that folder or some ancestor of it [and has not been overridden to disable at that folder])
However, you can edit web.config yourself to achieve that, like below:
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application,
please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="SilverlightAppNameTestPage.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Troubleshoot: WCF HTTP Error 404–Not Found
Copying from MPPVE (formerly RCE) documentation:
…might indicate that WCF is not correctly configured.
To resolve the WCF issue
- The error returned is a “HTTP Error 404 – Not Found”. This might be due to an issue with the WCF scriptmaps registrations. To solve this issue:
- Open a command line console as Administrator
- Browse to “%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\”
- Run the command “ServiceModelReg.exe –i”
btw, for some more troubleshooting tips regarding MPPVE and the CSM (Composite Stream Manifests) files the latest version creates in specific, checkout:
YouTube (Google) 502 error page
Η σελίδα σφάλματος του YouTube
500 Internal Server Error
Λυπούμαστε, κάτι δεν πήγε καλά.
Η διευθέτηση του ζητήματος έχει ανατεθεί σε μια άρτια εκπαιδευμένη ομάδα μαϊμούδων.
If you see them, show them this information:
IH6pYV6uW08aEw7RTmh2nctOCLKwYBoSQTT250UKk1Aq9OGTSu0MO16kB8kH IX8I1EZVDq2NHuva2SRpXGL6hG38xdffPCV3YBYJu8LVe1L9r7vz_fQrTavV aEsYIAILDGIATDB2OC78kZeqDUS9jeQzQqBiA6_Q7RDGkivkzT6XcaChvBAI TVWzwDPaNPJV8J7m2aqxgprbkCwzzcIfMD1toWoe4cbls7NqoBvCYAEsfZKD HlQ_3ylykRbFkJfi1HapcCFYJvnFB-6wyNYtgciyVuTEcieOHUq3-6zSAHk9 jzA1y2nndSZdSonvl5QTyCxWlrUzJR-ILxQuCmLI7iJgjl6r6rJCiR0G4ETR 4saaalM-MS2GGaikabqbENBLmtcerB5ZM37s-CgMgfbgxjTDb6__Te4_hveU H0mFIVTykRF3KkJKNTbKnXgzZ8l3OxU1KFiPL3Qsbnk5XADrMx1ThvgRWS-C wANkQ3C7EM0TDm0Xfwl4lVg2tE_eGmdktkmSzIpK3mnzZMUJ5TPhpchuoE_H kSIcV16f_p2phAfJsjbwKs11szwt_HLlEyeH1MUizpvNcrMh8qzDcd2H8siN mtkBjG0NrRjPyh2Cv8VIxfY__LpSJQ5J-V8t7ee9wFgmRrwL0MbzOopueiV_ SccnIpDai8vLFWAnA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