Static Content error debbug in localhost with VisualStudio - asp.net-mvc-5

I have added some mime that I needed for my project in MVC5 because in production it did not work.
<system.webServer>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
<mimeMap fileExtension=".js.min" mimeType="text/javascript" />
</staticContent>
</system.webServer>
Once added I have published and the app works correctly.
When trying to debug the app in local with VisualStudio, it doesn't find any mime.
If I comment the code of the Web.config it works correctly in local but not in production.
How can I not be commenting and uncommenting this code?

I have made the following implementation and I have managed to make everything work correctly both in the production version and in the local version
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
<remove fileExtension=".js.min" />
<mimeMap fileExtension=".js.min" mimeType="text/javascript" />
</staticContent>
</system.webServer>
I could find the solution here reference

Related

Deploy angular universal on IIS 10

I am trying to deploy angular universal on IIS 10, I followed this article https://www.thecodehubs.com/how-to-deploy-ssr-angular-universal-to-iis/
This is my Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="main.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<match url="/*" />
<action type="Rewrite" url="main.js"/>
</rule>
<rule name="StaticContent" stopProcessing="true">
<match url="([\S]+[.](jpg|jpeg|gif|css|png|js|ts|cscc|less|ico|html|map|svg))" />
<action type="None" />
</rule>
</rules>
</rewrite>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" />
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/x-woff" />
<mimeMap fileExtension=".otf" mimeType="application/otf" />
</staticContent>
</system.webServer>
</configuration>
This is my app folder on IIS
But when i start my website on IIS, I got this error
The iisnode module is unable to start the node.exe process. Make sure the node.exe executable is available at the location specified in the system.webServer/iisnode/#nodeProcessCommandLine element of web.config. By default node.exe is expected in one of the directories listed in the PATH environment variable.
So I added this line to my web.config file just before </system.webServer>
<iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
</system.webServer>
</configuration>
But the same problem still exists. this is my ProgramFiles, here i noticed that the nodejs has shortcut , I am using nvm (node version manager). Is this the reason ?
Yes you are right, this is because you are using nvm, i faced this issue before.
Switch off node version manager by running in cmd
nvm off
Install node js on your machine, then it will run without any issue.

How to allow .appxbundle file extension on Azure WebApplication?

A basic question, but I can not find how to do this.
I need to put a .appxbundle file hosted on a Azure WebApplication, but when I try to download, it
The resource you are looking for has been removed, had its name
changed, or is temporarily unavailable.
If, for example, I rename to .appxbundle.zip, then the file downloads normally.
I solved adding the staticContent tag on the Web.config file, under system.webServer, as follows:
<?xml version="1.0"?>
<system.webServer>
<staticContent>
<remove fileExtension=".appinstaller" />
<remove fileExtension=".appxbundle" />
<remove fileExtension=".cer" />
<remove fileExtension=".ps1" />
<remove fileExtension=".psd1" />
<remove fileExtension=".appx" />
<mimeMap fileExtension=".appinstaller" mimeType="application/xml" />
<mimeMap fileExtension=".appxbundle" mimeType="application/xml" />
<mimeMap fileExtension=".cer" mimeType="application/x-x509-ca-cert" />
<mimeMap fileExtension=".ps1" mimeType="text/plain" />
<mimeMap fileExtension=".psd1" mimeType="text/plain" />
<mimeMap fileExtension=".appx" mimeType="application/vns.ms-appx" />
</staticContent>
</system.webServer>
Source: https://blogs.msdn.microsoft.com/africaapps/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website/

How to web serve a file without an extension on GoDaddy's web hosting service?

When setting up universal links for iOS apps, Apple states:
Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle.
Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the
.well-known subdirectory.
We have created a file named "apple-app-site-association" without an extension, but if navigate to "http://ourdomain.com/apple-app-site-association" we get a 404 file not found error.
Apple specifies not to add a .json to the filename.
We see another SO overflow answer describing configuration changes to IIS to serve files without extensions. But what is the trick to getting this file to be served properly from GoDaddy's Linux or IIS servers?
I was able to get this to work by adding an .htaccess file at the root level that contains:
<Files "apple-app-site-association">
ForceType application/json
</Files>
Oddly, I could not get this to work if I tried to put the apple-app-site-association and the .htaccess files in the .well_known directory.
With this configuration, the validator here https://branch.io/resources/universal-links/ was all green and the links themselves worked.
This is what worked for us.
We put this text in a file named "web.config" in our main web directory along with the apple-app-site-association file.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".xml"/>
<remove fileExtension=".svg" />
<remove fileExtension=".ttf" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".json" />
<remove fileExtension=".otf" />
<remove fileExtension=".mp4" />
<remove fileExtension=".zip"/>
<remove fileExtension=".eps"/>
<remove fileExtension=".pdf"/>
<mimeMap fileExtension=".pdf" mimeType="application/pdf" />
<mimeMap fileExtension=".zip" mimeType="application/zip"/>
<mimeMap fileExtension=".eps" mimeType="application/octet-stream"/>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".otf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".xml" mimeType="text/xml" />
<mimeMap fileExtension="." mimeType="application/pkcs7-mime"/>
</staticContent>
</system.webServer>
</configuration>
Of note, that properly serves the file without an extension - BUT - as we understand it - Apple still requires two other steps. (1) Your server must get an SSL certificate so it can serve that file by HTTPS (that is a ~$60/year purchase on GoDaddy); (2) Your server must also code-sign the apple-app-site-association file (that is a ~$150/year on GoDaddy for a downloadable certificate which can code sign files.)

Azure web app configuration for MP4

There seems to be a strange problem with my Azure webapp. I can't view MP4 files on my browser at all. After exploring few articles here, I did the following:
I use Github continuous deployment, so I created a new file called "Web.config". The content of it is the following:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<remove fileExtension=".mp4" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
</system.webServer>
</configuration>
I made sure on the FTP that the file exists in the '/site/wwwroot' directory, and it does. I also made sure the MP4 file exists on the FTP in an accessible location.
The error I get on the website is the following:
The resource you are looking for has been removed, had its name
changed, or is temporarily unavailable.
Can anyone help me debug this problem?
Following our discussion, your web.config is right.
You have to make sure to locate it in the right location to make it works (the virtual application root in your case).
As Azure App Service is using IIS, you can find more details regarding IIS configuration files here: http://www.iis.net/learn/get-started/planning-your-iis-architecture/deep-dive-into-iis-configuration-with-iis-7-and-iis-8
I hope this helps,

Use SVG in Windows Azure Websites

Does anyone know if it is possible to add the SVG mime type to a Windows Azure Website?
I tried with a web.config file but that only broke my website.
Is this a limitation of the current preview or am I missing something?
thanks for your help!
What you can do in Windows Azure Websites (on web.config level) is pretty limited, but you should be allowed to add the mime type under staticContent:
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Others like me may have reached here having the same problem not resolved because of other related file types, in my case I also needed .eot and .woff mime mappings.
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
</staticContent>
</system.webServer>

Resources