mimeMap still does not display my svg - html

I am sorry if it is something novice or silly but this is my first time using a web.config file.
I have been dealing with the pleasure of godaddy not provide svg support by default. So I found some info on using a web.config file to inform the browser what to do with this file type.
Sources
Link 1
Link 2
Link 3
I am able to get the file in the server without crashing everything. The website will still display instead of displaying a 500 (internal) error but the svg still does nothing.
Here is my web.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="images/svg+xml" />
<remove fileExtension=".svgz" />
<mimeMap fileExtension=".svgz" mimeType="images/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Does anyone know what I am doing wrong? I also put the file into the main root file on the server but no luck.
Live site if it helps: Mobile app design

It appears your mimeType is incorrect. Remove the "s" from the images:
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
reference, if you like documentation

Related

Block direct access to mp4 videos while allowing them from viewing within the website using web.config

I am trying to block (using web.config) direct access to mp4 videos while allowing videos to be played within the website:
Here's my current web.config's content. This blocks videos to be played on my HTML page as well as direct access.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".mp4" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
How can I allow video to be played on HTML while blocking direct access?
You can put your “Uploads” folder outside the website directory, so if your website exists on “c:\website” you can put the “Uploads” there “c:\Uploads”, Like that IIS has no control over this folder and its files, And your website code will still have access to this directory as a normal physical path.
or you could try to set the hidden segment in web.config file:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="Uploads" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>

Issue with videos in a deployed web in AZURE

I'm having a problem with a deployed webapp service in AZURE, the videos contained in the web page are not working.
The message is the next one:
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
The HTML code is the next one:
<i class="icon-play2"></i>
Can anyone help me please?
Thanks!
As #Offbeatmammal mentioned, we need to configure the MIME types in web config file before we use the specific file type in our web application. Since your video type is mp4, you need to add following configuration into < system.webServer > tag.
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
Yes thank you! Solved with a web.config file!
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4"/>
<mimeMap fileExtension=".ogv" mimeType="video/ogg"/>
<mimeMap fileExtension=".webm" mimeType="video/webm"/>
</staticContent>
</system.webServer>

Azure custom 404 page

I have created a web application using Microsoft Azure and uploaded static html pages to the web application.
It works fine, however, I would like to set a custom 404 page. Where or how can I do this using the Azure portal ?
Just to be clear, this is not a visual studio project, it's just some static html files. I just want to tell azure to use my 404 page instead of the default text it displays when a page cannot be found.
EDIT
Please note, this has nothing to do with IIS. I dont even have a web.config file. I am simply hosting some static html files in Azure and want a custom 404 page. I have already made the 404.html page.
Seems like you have to add a web.config file in your root directory. This seems like a workaround, but doing that and adding the following code works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Follow these steps to configure a custom 404 page for a Azure Static Web App:
Create a file named staticwebapp.config.json in root page (same folder as starting page i.e. index.html)
put these lines inside it:
{
"responseOverrides": {
"404": {
"rewrite": "/404.html"
}
}
}
Put your custom 404 page in root or subfolder (in this example 404.html is in root folder)
After a lot of testing and research, it was found that using responseMode="ExecuteURL" would result in a correct redirect, but the browser would report 200 Status rather than a 404. To fix this we removed the "/" and changed to responseMode="File" based on insight from this post: web.config errors fail with responseMode="File"
We are just hosting a simple static HTML site, not a web app, and this code worked:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors defaultRedirect="404.html" mode="RemoteOnly">
<error statusCode="404" redirect="404.html" />
<error statusCode="500" redirect="500.html" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors existingResponse="Replace" defaultResponseMode="File" errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="404.html" responseMode="File" />
<remove statusCode="500" />
<error statusCode="500" path="500.html" responseMode="File" />
</httpErrors>
</system.webServer>
</configuration>

json mime-type on 2003 server issue

Here is my issue:
I have a solution working on a 2003 server with iis 6
And every time I deploy the solution I have to configure the MIME type on the iis.
I have implemented this in my web.config, but it doesn't seem to work properly.
<staticContent>
<remove
fileExtension=".json" />
<mimeMap
fileExtension=".json"
mimeType="application/json" />
</staticContent>
Is there a global way of setting this up?
I think I found a solution to the problem, add this code on top of the other and it worked.
<system.web>
<staticContent>
<remove
fileExtension=".json" />
<mimeMap
fileExtension=".json"
mimeType="application/json" />
</staticContent>
</system.web>
The issue was that the <system.webserver> not allways works on 2003 server, therfore the <system.web> was needed also.

Windows Azure Website and static html in Blob storage

So I have a .NET MVC app published in an Azure Website which should serve static html pages stored in a blob container when clicking on a corresponding hyperlink.
My questions are:
The way to access a blob in Azure is
https://blobtest.blob.core.windows.net/container/htmlpage1.html,
however the peculiar part is when I login into my Azure Site and the url is
something like:
http://azuretestwebapp.azurewebsites.net/user123 and if I click
on a hyperlink to my html blob it can't help but normally take me to
blob azure site (well of course). Therefore I am wondering if there
is a way to have a url similar to this:
http://azuretestwebapp.azurewebsites.net/user123/container/htmlpage1.html
considering that the html pages are stored elsewhere in Azure.
If this is not feasible using an Azure Website or by storing
static html pages in Blob, what would be a better approach?
Thank you in advance for your time.
You can modify your web.config for your site to forward requests for static pages to blob storage using a redirect rule. Then the static content will be stored in and served from blob storage.
Place the following in a file named web.config (or modify your existing web.config) and put the web.config in the folder site/wwwroot on your website, next to the site content.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="static" stopProcessing="true">
<match url="static/(.*)" />
<action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Better late than never. Azure Blob requires the host header to be set correctly also otherwise it'll 404.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="static" stopProcessing="true">
<match url="static/(.*)" />
<action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />
<serverVariables>
<set name="HTTP_HOST" value="blobtest.blob.core.windows.net" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Please remember to Allow Server Variable {HTTP_HOST} in URL rewrite.
https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/setting-http-request-headers-and-iis-server-variables
You could also set this in applicationhost.config section.
<location path="Default Web Site">
<system.webServer>
<rewrite>
<allowedServerVariables>
<add name="HTTP_HOST" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</location>