Insert a raw image in my Website - c#

I've got a raw image : either a Bitmap object, or a byte[]. How may I include it in my website (in an .cshtml file), without saving it on my computer ?
I'm using c#, and the project follow the MVC structure.

You can put the image in your html as a base64 string. However, You do need to know the mime-type of the image as well because that has to be prefixed to the string.
For example:
<img src="data:#mime;base64,#(Convert.ToBase64String(bytes))" />
As a rendered example, this will show a dot:
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

Related

Retrieve and display inline images from email when encoded as a CID with c#

I need the image URL from the following cid code in the physical path
<img id="Picture_x0020_6" src="cid:image001.png#0e4yt5586.A7D64B40" alt="cid:image009.png#34ty6CC2.1CD154B0" />
as
<img id="Picture_x0020_6" src="~/images/image009.png" alt="image009.png" />
You need to find the corresponding hidden attachment and then save it on the disk. The SaveAsFile method of the Attachment class saves the attachment to the specified path. Then you can upload it to any web server or just make it available globally and change the src attribute in the message body.

Razor with Url.Content helper is ending quotes at space in URL

I'm using ASP.NET Core 2 with Razor to try and pass an image URL into the View via a ViewModel. Unfortunately, the image URL has spaces in it, which I don't have control over at the moment.
I have a file name like this (note the space):
https://example.com/images/file name.jpg
I'm using Razor to try and show the image like this:
<img src=#item.ImageUrl />
The output HTML looks like this:
<img src="https://example.com/images/file" name.jpg />
Obviously this will not do! I should mention, we know this all works when we use an image that has no spaces in the file name. Here are some ways I've tried to correct the issue:
Using Url.Content helper in Razor (this did not make a difference):
<img src=#Url.Content(item.ImageUrl) />
Using System.Web.HttpUtility.UrlEncode when populating the ViewModel (this results in a "double-encoding" error):
myViewModel.ImageUrl = HttpUtility.UrlEncode(someUrl);
My goal is to get the URL encoded properly (no "double-encoding" and no truncating at the space in the input string). How can I achieve this goal?
The problem is that Razor will attempt to create valid HTML, so when it sees a space it automatically closes the quotation marks, so:
#{string img = "a a.jpg";}
<img src=#img />
Gets rendered as
<img src="a "a.jpg /> // of course invalid
So, you need to be sure you include your quotation marks, then Razor will use them:
<img src="#img" />
Which gets rendered as
<img src="a a.jpg" />
You can try
<img src="#Html.Raw(item.ImageUrl)" />
but I agree that using invalid URLs (with spaces) doesn't seem very useful in the long run.

reading xml image data with c#

I have just got an xml file :
<?xml version="1.0" encoding="utf-8"?>
<somenamespace xmlns="http://...">
<Image type="jpeg">/9j/4AAQSkZJRgABAQEAwADAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADwAUADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDMwM8daXkClVMZNOAycC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ouBb3sts1xaS2U3lqh8yGTbvU7lOM7RyMH3rOuLm6trT7ILqT7D9s+2fZ9qbfO8vyt2du77vGM49qtYO/PWi6jSS2IYDNCVtRWuSaf4z8Q2ehrpNn4jv4LFIzDHGoiLRoc/KsjIXGAcA7sqAMEYFQ6dqM2mammqabqFzaagvmbrlHEjyByWcP5gYOCx3fMDzgjmudkhMcm3tTWUryDTUkFjp72/utS1WTU9QvZr6+kRYzPNtBVB0RQoCqucnAAySScmmlyyHtXOW2oENtYng+laq3Kuo+Y1rFk6n/9k=</Image>
</somenamespace>
I am writing an asp.net app that just displays the actual image to the browser. First question is why is the image stored as such a randomly long string? Second question how would i render the actual image in an asp.net web app - is it even possible?
That looks like a Base64 encoded string. You can display it in HTML by appropriately setting your src attribute:
<img src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAwADAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADwAUADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSM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oo6Zq99aX12Xa7njWI/aWZy+50ZCmQWbBCggEjpWkuHUH161D3IFVYgprHN9tmurq9ur68n4knupS7EbmYKBwqKC7YVQAM9KlO3HXmpniA5PArJuJgGGPXmiwEjX93pt+l/p2oXFldxxPDviSNtyOUJBEiMOqL0qpqeua5riW6arrNzeQ28vnRxvDAgD7WTOUjU9HbvVjKSRk98VnTMFByaVgK7vMouBb3sts1xaS2U3lqh8yGTbvU7lOM7RyMH3rOuLm6trT7ILqT7D9s+2fZ9qbfO8vyt2du77vGM49qtYO/PWi6jSS2IYDNCVtRWuSaf4z8Q2ehrpNn4jv4LFIzDHGoiLRoc/KsjIXGAcA7sqAMEYFQ6dqM2mammqabqFzaagvmbrlHEjyByWcP5gYOCx3fMDzgjmudkhMcm3tTWUryDTUkFjp72/utS1WTU9QvZr6+kRYzPNtBVB0RQoCqucnAAySScmmlyyHtXOW2oENtYng+laq3Kuo+Y1rFk6n/9k=" />
The binary sequence for the image can't be safely stored in the XML file due it's text nature, so it's converted to a base64 string.
Yes, most browsers can show that kind of data; take a look into this question for more background: Embedding Base64 Images

Rendering Image using Base-64 string: ASP.NET vs HTML

I am retrieving a base-64 string that is a representation of an image from the database. When I try to render the image in HTML, like this:
<img src="my base-64 string" />
The string gets broken up and doesn't render correctly. However, when I use the same string and attempt to render the image using ASP.NET, like this:
<asp:Image runat="server" ImageUrl="my base-64 string" />
It works successfully. A case has arisen in which I need to bind the HTML image source to a new base-64 string on the client side, therefore necessitating that I use the first method. Is there any way to accomplish this?

Display varbinary as a downloadable link

Fairly straightforward question, I have images stored in my database as varbinary and would like to provide a link to these images rather than displaying them on the website. When a user clicks the link he/she should be able to download the image.
An image is served in response to a request.
<img src="?" /> <!-- what goes here? -->
You need to create an HTTP handler to receive requests for these images.
A handler is an executable available at a specific URL which can respond to your request; in this case, by serving the binary data of an image. An ASPX page is a valid handler, though there are more efficient handler types for images.
<img src="MyHandler.aspx?imageId=123" />
The handler should do a few things:
validate that the ID is valid and that the caller has permissions (if needed)
retrieve the image from the database
set appropriate response headers
use Response.BinaryWrite() to send the binar data to the client.
Note that if you are using ASP.Net MVC, you can use a controller as your handler.
An alternative method is to base 64 encode the bytes and embed them directly in the image tag.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">
This is a useful technique for small images or when the expense of multiple requests is very high.
See: http://en.wikipedia.org/wiki/Data_URI_scheme
More reading:
Dynamically Rendering asp:Image from BLOB entry in ASP.NET
Dynamic Image Generation
You should create a page that takes an image-id and returns the image.
You may consider this question:
Display image from a datatable in asp:image in code-behind
I had a similar problem an that answer solved my question. Beside that, you can use binaryimage component from Telerik:
http://www.telerik.com/products/aspnet-ajax/binaryimage.aspx

Categories

Resources