SharePoint 2013 Hosting :: How to Solve SharePoint 2013 Fails to Render Image

I as of late updated a SharePoint 2010 custom answer for SharePoint 2013. One of the issues I went over was that on certain custom pages the pictures no more showed accurately. As opposed to showing a picture, the page or control would be clear or the client would be provoked to download a document. The same code dealt with a SharePoint 2010 homestead and I couldn’t discover any conspicuous exemptions in the SharePoint logs.

ahp banner sharepoint-01

With a specific end goal to outline the issue (and arrangement) I made the accompanying basic custom undertaking:

My sample undertaking contains a SharePoint 2010 Visual Web Part which contains one catch. The catch utilizes JQuery to demonstrate a custom page from the _Layouts envelope. The custom page contains code-behind which will show a picture from the current web “Pictures” library.

I tried the arrangement in Visual Studio 2010 and all worked fine. At the point when the client click on the catch, the custom page is indicated and it renders the picture obviously.

How to Solve SharePoint 2013 Fails to Render Image

However when I form and send the same venture in SharePoint 2013 the custom page does not demonstrate the picture, rather the client is incited to download a record.

How to Solve SharePoint 2013 Fails to Render Image2

My partner Hennie van Wyk immediately found that there is a contrast between the SharePoint 2010 and SharePoint 2013 Web App’s HTTP Response Headers in IIS.

In the event that you open IIS Manager and go to the HTTP Response Headers of the important SharePoint Web App you will see that in SharePoint 2013 two new host headers are presented.

They are “X-Content-Type-Options” with a worth “nosniff” and “X-MS-InvokeApp” with an esteem “1; RequireReadOnly”.

How to Solve SharePoint 2013 Fails to Render Image3

How to Solve SharePoint 2013 Fails to Render Image4

We further found that in the event that we erase the X-Content-Type-Options reaction header the custom code worked and the pictures showed on the custom page. I would prefer not to erase or cripple standard SharePoint design and I positively can’t anticipate that my clients will do likewise so I chose to examine the likelihood of changing the custom code so it renders the new picture paying little mind to the “X-Content-Type-Options” reaction header.

Things being what they are, what is the X-Content-Type-Options reaction header?

I discovered an exceptionally supportive blog entry by Mark Jones in which he clarifies that the X-Content-Type-Options reaction header with an estimation of “nosniff” is an order from IIS that advises the program to not sniff the MIME sort. At the point when this is incapacitated IE won’t attempt to consequently figure out what your substance is. E.g. HTML, PNG, CSS, script, and so on…

This implies that its dependent upon the engineer to tell the program what your substance is. What’s more, if what you are sending down isn’t in IE’s permissible show it is set decline to execute your substance, subsequently the clear regions of the screen.

On the off chance that the “nosniff” order is gotten on a reaction recovered by a script reference, Internet Explorer won’t stack the “script” document unless the MIME sort coordinates one of the qualities”.

I likewise discovered the accompanying incredible article composed by Charles Torvalds.

Next step, how about we attempt to alter our custom code…

In the sample SharePoint 2010 undertaking which I produced for this blog entry I had the accompanying code in the Page_Load occasion of the custom page. This represents that when the page stacks the code will recover the first thing from the pictures library and render the picture.

Note that the accompanying line of code sets the reaction MIME sort to “application/octet-stream”. Response.ContentType = “application/octet-stream”;

The code worked fine in a SharePoint 2010 web application in light of the fact that in SharePoint 2010 there is no default X-Content-Type-Options reaction header with a “nosniff” esteem.

I changed the code to rather indicate a Mime kind of “picture/png” and I sent it to my SharePoint 2013 web application and everything worked fine.

How to Solve SharePoint 2013 Fails to Render Image5

This may be an exceptionally straightforward illustration of a potential genuine test when you overhaul SharePoint 2007 or SharePoint 2010 answers for SharePoint 2013.

In his blog entry Mark Jones additionally say illustrations where he discovered Javascript with a MIME kind of “content/clear” which ought to have been “application/javascript” and in different cases JSON which was sent down as “application/json” when it ought to have been “application/javascript”. I can just envision that there are several comparable cases.

This may be a very simple example of a potential serious challenge when you upgrade SharePoint 2007 or SharePoint 2010 solutions to SharePoint 2013.

Top 3 SharePoint 2013 Hosting Recommendation

ASPHostPortal.com

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers SharePoint 2013 hosting starts from $9,99/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable SharePoint 2013 Hosting, ASPHostPortal.com should be your best choice.

HostForLIFE.eu

The price of HostForLIFE.eu SharePoint 2013 hosting packages is quite competitive, especially the Level 1 which we may recommend most here. The Level 1 hosting package is €9.99/mo. It include 50GB bandwidth, 5 GB disk storage, MSSQL 2012 databases, MySQL databases, Unlimited Subsites and support almost all of the cutting-edge Windows technologies, such as remote IIS management, ASP.NET v5 and Full Trust. Hosting a Windows-based website with HostForLife.eu should be absolutely worry-free.

DiscountService.com.au

DiscountService.com.au is Microsoft Gold Partner, which means they will be the first one to know the latest Microsoft technology and test Microsoft product before being released to the public. With tons of positive feedback from their customers, we are glad to grant them as the Best SharePoint 2013 Hosting of this month. Their SharePoint hosting is sold at $10/month only, each account is allocated with large Bandwith and Storage Space. It’s sufficient to run a website which is not very busy.