Updating Azure App Service web.config to load .ttf font files - azure

Wracking my brain but can't seem to find the solution. I have a .ttf font file, located on Azure storage blob, being used for a custom font on my Azure App Service site. I get a 404 "resource not found" error for this file.
After reading a ton of documentation on this, it seems I need to add a couple of lines of code, for a new "mimetype", to the web.config file. Older versions of Azure had this in "Extensions" or "Application Settings".
Other people show the ability to do so in Kudu under the "Debug" option. However, I can't seem to find either of those - "Configuration" shows environment variables and I don't see a "Debub" option in my Kudu portal.
Kudu Console without "Debug" option
How do I actually update the web.config file or at the very least be able to load a .ttf file???

Go to Kudu, then go to wwwroot folder and edit web.config file with the following, or just create one in case it's not there:
PS: previous image shows LogFiles folder, but it should be wwwwroot
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Related

.NET CORE 3.1 on Azure Web Sites: 500.37 ANCM Failed to Start Within Startup Time Limit

I have .NET Core 3.1 API which is deployed in Azure web application service. I had trouble running the application in Azure because of the error 500.37 ANCM Failed to Start Within Startup Time Limit. I managed to solve this issue by increasing startupTimeLimit in web.config (as you can see below).
But Now, when I'm running 2 instances in Azure web app service. One of the instances works just fine but the other one still has the same error.
Any ideas on how How to set startupTimeLimit for multiple instances in IIS?
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Clients.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="180" hostingModel="inprocess" >
</aspNetCore>
</system.webServer>
</configuration>
Edit:
I used azure web app Scale out (App Service plan) to increase the running instance to 2.
We solved this solution by increasing the startupTimeLimit to 300
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location>
<system.webServer>
<aspNetCore xdt:Transform="SetAttributes(startupTimeLimit)" startupTimeLimit="300">
</aspNetCore>
</system.webServer>
</location>
</configuration>
Finally I was able to fix this error.
It is a configuration error (.net core configuration). Azure App Services need an additional configuration of the project when it is in .net core 3.1.
The solution is:
In project file (asp.net or web api project) (*.proj) you have to place the following line just below TargetFramework:
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
Final *.proj file would be something like this :
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<UserSecretsId>my-secrets-go-here</UserSecretsId>
<Version>1.1.0.0</Version>
<Authors>me</Authors>
<Company>TheCompany</Company>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
...
</Project>
And that's it. After adding those changes and uploading a new version on your Azure App Service the application is going to be executed without errors (unless there's something else related to your code).
I was able to replicate this error by executing my project directly on IIS from my local, when you do that VS opens the web browser but the web page is never loaded.
Started getting this error when running my .net core 3.1 application on production. The error occurs immediately after updating the application. However, for me, running iisreset on cmd was enough to solve the error.
if application work perfect on development machine and this error exist on your production server that is not connected to internet
check event log and find if you have any error like this:
Failed extract of third-party root list from auto update cab at
you need just update server certificates
with Online option : connect server to internet
with Offline option: follow this guide

Can't get SVG served from Azure

I'm building a static HTML5 web site on VS2014 and deploying via Dropbox to be hosted on Azure. All works using F5 on VS2014. But my SVG images do not get served from Azure. I get HTTP/1.1 404 Not Found errors. I have tried this solution:
Use SVG in Windows Azure Websites and the code snippet suggested by Mads Kristensen at http://madskristensen.net/post/prepare-webconfig-for-html5-and-css3. My web.Debug.config & web.Release.config files are both as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<staticContent>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
Here's the question. What should I do to get my svg files to download?
EDIT: I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.
I found the problem. As a relative new user of VS2014 and Azure, I overlooked the higher level Web.config file and only worked with the lower two files mentioned above. Putting the additional staticContent lines into the Web.config file fixed everything.

Google Earth (.kmz) mime type IIS issue

I am experiencing a peculiar issue with IIS and KMZ files. I have added the MIME type to IIS and it works just fine -- however, seemingly randomly the MIME type is removed. This has happened a few times now, and each time all I have to do to fix the issue is just add the MIME type again.
The issue is identified when broken links are reported, and as soon as I add the MIME type back in all is well.
Any thoughts on what is causing it, or methods for finding out what's causing it?
Thanks!
My guess is that someone is overwriting or modifying your web.config file. You can modify the web.config using either the IIS server tools or by publishing the project containing the web.config file. If you are modifying your IIS settings using IIS Manager, then every time someone re-publishes the web application it changes those settings. Make sure the correct settings are saved in your web.config in your root VisualStudio project. So that whenever that project is published it's setting the correct IIS settings.
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".kml" />
<mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" />
<remove fileExtension=".kmz" />
<mimeMap fileExtension=".kmz" mimeType="application/vnd.google-earth.kmz" />
</staticContent>
</system.webServer>
</configuration>

How to include a non-standard font-face in azure hosted website without using visual studio?

Trying to use a custom font in a simple static content website publish via git to azure. The website project isn't wrapped in a Visual studio solution. There is no web.config so how can I get the custom font to work or any static content such as .json files to be accessible?
This solution implies your using visual studio which I am not. How to include a non-standard font-face in azure?
My exact error is:
Failed to load resource: the server responded with a status of 404 (Not Found) http://fakewebsitename.azurewebsites.net/fonts/fontawesome-webfont.woff?v=4.0.3
you just have to add a MIME type for the font in your web.config it will look something like this for your woff font
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>
</system.webServer>
</configuration>
IIS by default will prevent download of static files you don't specify MIME types for.
Edit: added <remove fileExtension=".woff" /> based on #TealFawn suggestion

iis 7 + http custom handler error: could not load file or assembly The system cannot find the file specified

Windows vista 32 bit - C# - .NET 4 - sqlite - IIS 7
I'm building a small project that contains is a custom HTTP handler where an user can request a XML file and the project will generate the file and send it to the user. It should be flexible enough to send something else too like e.g. json.
Everything was going well until I had to deploy the handler. I've created a library (dll) file which contains the logic for serving of the requested information. I've open IIS manager and I've created a virtual directory to the debug bin file (later on i made it an application. it did not make a difference).
I've followed countless examples and tutorials like these ones:
I started with this one: http://support.microsoft.com/kb/308001
http://msdn.microsoft.com/en-us/library/bb515343.aspx
msdn.microsoft.com/en-us/library/46c5ddfy.aspx
But with no luck. As you could have read I'm not using any asp.net website even though I do have a web.config that I've added to the bin folder and it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<directoryBrowse enabled="false" />
<handlers accessPolicy="Read, Script, Execute">
<add name="LigoManagedHandler" path="*" verb="*" type="Ligo.Service, Ligo" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
When I try to run handler in the browser get the following error:
Could not load file or assembly 'Ligo' or one of its dependencies. The system cannot find the file specified.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Ligo' or one of its dependencies. The system cannot find the file specified.
I have tried so many possible combination in IIS manager to get it working ('httphandlers', 'classic mode' and so on ...) but i'm truly stuck. The information I've found on the internet is not helping much.
What am I doing wrong or missing to make it work?
Something in this rant triggered an idea, an I stumbled on the answer.
The line in all those tutorials that say put type="ClassName, AssemblyName" into the Handlers section in Web.Config are plain WRONG.
All I did was change this to type="AssemblyName.ClassName" and everything started working, in both a Web Site Project and a Web Application Project that I had created.
I'm running IIS 7.5 in integrated mode so YMMV.
Craig
I figure it out. I had to make a asp.net website project and add my dll as reference to this project.
I read this thread that provided this information which is not clear on the internet.
http://forums.asp.net/t/1088861.aspx/1?What+causes+the+quot+Could+not+load+type+quot+problem+
It should state that it is not possible to make the httphandler without a aspnet website project. or am i mistaken? the example on the internet are incorrect! or provide too little information.
I know, this is an old thread. However, I've been looking for an answer for a few days without finding a clear one. So, in case anyone comes across similar scenario.
You can create custom Http Handler as a stand-alone Class Library project and use it in IIS.
On IIS Add new Application with ASP4 Integrated mode. Place your compiled DLL into bin folder (this is what i was missing all along). Seems obvious that it should be there; took some time to figure this out. :)
web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<handlers>
<add verb="*" path="*.ogg" name="test" type="Namespace.Classname"/>
</handlers>
</system.webServer>
</configuration>
Hope this helps.
Cheers.

Resources