Even though MIME-Type is set in IIS, cannot disply SVG file - svg

IIS MimeTypes
I have an image tag with an svg file:
<img src="/uploadedImages/temp/Example.svg?n=9368" alt="testsvg" title="testsvg" align="middle">
which won't display in any browser. I can see in Developer Tools that the Content-Type is coming through as application/octet-stream. However, in IIS 7.5, I DO have the MIME-Type set as image/svg+xml (see attached screenshot in link "IIS MimeTypes" above). I also tried setting it in the web.config as follows:
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
but that also did not help. What am I missing? How do I get the correct Mime-type to load so that the image can show in the browser?
(By the way, in IE, if I browse to the file's location, the image DOES show. But not in Chrome and Firefox, they merely want to download the file instead of display it.)

Related

How Can I have IIS properly serve .webmanifest files on my web site?

The Favicon Generator assembles a package for webmasters to use in order to have icons available for many different devices. The page comes with a file called site.manifest which is linked to via the following tag in the web page's document <head>:
<link rel="manifest" href="site.webmanifest">
According to Mozilla: "The web app manifest provides information about an application (such as name, author, icon, and description) in a JSON text file. The purpose of the manifest is to install web applications to the homescreen of a device, providing users with quicker access and a richer experience."
Unfortunately if you are using Microsoft's Internet Information Services (IIS), you'll get a 404.3 error if you try and access the site.webmanifest file.
The exact error message is as follows: "The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map."
How can I properly serve site.webmanifest files in IIS?
By default, IIS does not serve any files that does not have a MIME map associated with it in its (IIS) core settings.
To address this challenge, you will need to map the .webmanifest file extension to its appropriate MIME type.
To accomplish this, open IIS and follow the steps below;
On the left hand side, select either your web site or the entire server in the "Connections" menu.
If you select the server, your MIME mapping will apply to every web site on the server.
If you select a web site, it will only apply to a single web site.
Next, select "MIME Types" from the IIS menu:
Once there, click "add..." from the right hand menu.
In the dialog box that opens specify .webmanifest in the file name extension box application/manifest+json in the MIME type box.
Click "OK".
Congratulations; you've just defined the MIME type for .webmanifest on IIS.
For Azure I added this as the web.config
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
</system.webServer>
</configuration>
For those using ASP.NET Core (I am using 2.1) you can configure the MIME types that can be served in the application Startup.cs file as per the static files docs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
provider.Mappings[".webmanifest"] = "application/manifest+json";
app.UseStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = provider
});
app.UseMvc();
}
Easier solution is to rename your manifest file to site.webmanifest.json and link as
<link rel="manifest" href="site.webmanifest.json">
IIS should already have a MIME Type for .json files
This is also helpful if deploying to Azure where its not so easy to change the IIS settings.
Adding to #Ben's answer: if you have a SPA you should put StaticFileOptions code into the UseSpaStaticFiles() call:
FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
provider.Mappings[".webmanifest"] = "application/manifest+json";
app.UseSpaStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = provider
});
I found that the IIS server had ".json" listed in the Request Filtering feature saying it was not allowed.
Removing that allowed the file to be served.

Kentico sitemap not rendering with XML extension

I've gone through the documentation, set a page with the correct webpart, checked the web.config, and my sitemap only renders out the XML with .aspx.
here's my web.config snippet. I did make any changes here.
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<remove name="XHtmlModule" />
<remove name="CMSApplicationModule" />
<add name="XHtmlModule" type="CMS.OutputFilter.OutputFilterModule, CMS.OutputFilter" />
<add name="CMSApplicationModule" preCondition="managedHandler" type="CMS.Base.ApplicationModule, CMS.Base" />
</modules>
I even tried an alias on the portal page.
In your settings you can set this. Go to Settings>URLs and SEO>Search engine optimization (SEO) and the first 2 boxes are what you want to set. The first box (Google sitemap URL) is the actual URL you'll navigate to. The second box (Google sitemap path) is where in the content tree the Google sitemap URL will get the content from.
So to say it a different way, the path is the holder of the actual sitemap content. While the URL is where you will actually navigate to to get the sitemap.
For instance if you have sitemap.xml in the Google sitemap path and your actual sitemap is located in the content tree at /special-pages/google-site-map you'd never navigate to the /special-pages/google-site-map page, only the /sitemap.xml page and that is what you'd submit to the search engines as well.

Windows Azure ignoring files with unknown extensions

I have uploaded my website to windows azure. The website is working properly on the local server.
I am uploading images to the server.
ISSUE:
If the files had some weird names like 2013_6_5_15_12_33_144pwzve.lg2
Windows azure shows 404 error
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
But works with this file name 2013_6_5_12_1_5_SampleStudent.png
I created some sample page to check if file is uploaded successfully it is.
All the files are on the server.
I checked using grid
grvNotSent.DataSource = Directory.GetFiles(Server.MapPath("~/Test"));
Any idea?
Any help is appreciated
Thanks
what is LG2? Have you added a mime type for that file extension in the web.config?
You can add the mime type mapping like this:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".lg2" mimeType="whatever_this_type_is" />
</staticContent>
</system.webServer>
When IIS sees unknown mime type it ignores the request with 404.

404 page in Umbraco?

I installed Umbraco 4.5 and it is running fine. one thing i cant get to work though, is the 404. When it hit a page that does not excist it shows the default IIS7 404 page, and not the built-in umbraco 404 page.
So i am asuming it is a setting in the iis i have to change - but which?
Copy from http://our.umbraco.org/forum/using/ui-questions/8244-IIS7--404:
Basically, you need to add
<location path="Site Description">
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</location>
to your applicationHost.config file where "Site Description" is the name of your site in IIS7.
The applicationHost.config file is located in: system32\inetsrv\config
Edit:
As stated in the comments if this answer, you should add this section in your web.config instead which is way better, you should always avoid altering config files outside your own application that may affect other applications.
in config/umbraco.settings you can set the umbraco page to load for custom 404
<errors>
<!-- the id of the page that should be shown if the page is not found -->
<!-- <errorPage culture="default">1</errorPage>-->
<!-- <errorPage culture="en-US">200</errorPage>-->
<error404>1296`</error404>`
</errors>
The page error page ID goes between the <error404> & </error404> tags.

iis only Add Expires headers to images

Add expires headers in iis is very Easy,but this cache all the static files. now i want only
add expires headers to images,how can i do that? even i want cached specific file?
put all your images in one folder
enter the manager--> yoursite--> images folder (or specific file)
right click--> HTTP HEADERs--> Set expire header/date ! --> APPLY/OK
I've been searching for a simpler solution and I found this.
Keep your static content inside a folder (eg: css, js). Create a web.config file inside that folder. Add these following lines. Here 7 is the number of days, change it as you desire.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
You are free to keep as many static content folder as you want, simply add this web.config file. Hope this helps.

Resources