I have a model that has a property like "SomeUrl", it's an absolute url with some parameters in it, something like this for example: http://www.someexternalsite.com/q?param1=value1¶m2=value2
My view takes a List and I am trying to use these url's in an anchor tag like this:
my link
The url is being encoded and ends up coming out like this:
http://www.someexternalsite.com/q?param1=value1¶m2=value
How do I stop it from doing that?
Not encoding the & would result in invalid html. In this case the html is correctly encoded. If you want to render a string not encoded use:
#Html.Raw(...)
Change your link to this:
my link
Related
I have an application that gets a JSON file via a web service. The JSON is fairly large, and represents a Person object, with typical properties such as first name, last name, title and image for example. The person's image is stored as a base64 field in the JSON. It is bound to an image tag using Angular. So for example, the HTML looks like this:
<img ng-src="data:image/jpeg;base64,{{ person.fileImage }}">
When the end user right clicks on the image and chooses to save the image, the browser defaults to the name "download.jpg". What I need to do is name the image so that when the user right clicks and chooses to save, it gives a meaningful filename, e.g.:
todd.davis.jpg
I'm not sure how to make this happen. I've seen some solutions that use an anchor tag with a download="todd.jpg" parameter, but that is not working for me. I think it expects an actual URL and in this case, I don't really have one. The image data is just embedded in the JSON.
Is there a way to manipulate this so that I can add a name to the image for saving purposes?
I have human friendly urls without index.php. I had to modify .htaccess file for that. Actually I always use Codeigniter like this. My url-s always look like this:
www.example.com/controller/function/parameter
So if I have an extra url parameter, then the url looks like this:
www.example.com/controller/function/parameter?archive=2013
Now what I want to do: If there is 'archive' parameter in the url, than also add that to the url when anchor function creates a link.
We have some different stuff every year (like stylesheets), so I need to make this navigation automatic. Am I thinking in the right direction?
And the answer is "Yes".
I slightly modified the solution from here:
How to extend anchor() function to anchor_admin() in CodeIgniter?
I have a Servlet that I've designated as the welcome page for my Java Web Application. In the Servlets doGet method, I retrieve a list of Product objects from the database. The Product object is composed of: an ID, Name, Description, and Image(byte[]).
I then add the list of Products to the request as an attribute, and forward to a JSP where I want to display all of the products(in a table). Displaying the properties like name, id, and description are easy.
My problem is, I'm not sure how to display the image. Any ideas?
You would need to base 64 encode the image data and generate a data url which look like this:
data:image/png;base64,21fe8w4r7qwe/f4sd68f4/er41we5f1sd/1a3/13dfvd21
Something like this code would do the trick:
String url = "data:image/png;base64," + Base64.encode(bytes);
then use that url as your image src.
I'm having a bad time trying to implement a simple PinIt button.
I followed all the process and it works fine, with an exception: it is removing the Media parameter from the anchor tag.
This means that the PinIt button will open a window showing all the images from that page and the user needs to select one.
The source is ok:
<img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_white_20.png" />
But, when the page is loaded, the pinit.js is replacing the parameters.
I have tried to find a solution on the web and read something about the URL Enconde, I have tried with UTF-8 and ISO-8859-1 but without success.
The rendered html is:
<span class="PIN_1395089773564_hidden" id="PIN_1395089773564_pin_count_0"><i></i></span>
The media parameter is there, empty.
Thanks for your time,
William Borgo.
I believe the problem is actually in your url parameter. It cannot contain hashtags or other types of parameters. If you delete ?idItem=6920 from the url it will probably work.
I think your URL encoding is incorrect and is confusing Pinterest as to what is part of the Pinterest URL and what is part of one of the parameters - essentially where each parameter begins and ends, and what's a separate parameter for Pinterest vs a continuation of a previous parameter. (This is really the purpose of URL encoding for parameters.)
That is, the overall Pinterest URL should be like:
www.pinterest.com/pin/create/button/?url=[url]&media=[media]&description=[description]
The "&" separating the url, media, and description parameters should NOT be encoded. But each of the parameters themselves (the parts in [brackets]) SHOULD be encoded.
So for instance:
https://www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.tokstok.com.br%2Fvitrine%2Fproduto.jsf%3FidItem%3D121826&media=http%3A%2F%2Fwww.tokstok.com.br%2Fpnv%2F570%2Fc%2Fconnmlt_czbr1.jpg&description=CONNECTION%20MESA%20PARA%20LAPTOP
...which you could look at like this (with line breaks between parameters and some spacing):
https://www.pinterest.com/pin/create/button/
?url = http%3A%2F%2Fwww.tokstok.com.br%2Fvitrine%2Fproduto.jsf%3FidItem%3D121826
&media = http%3A%2F%2Fwww.tokstok.com.br%2Fpnv%2F570%2Fc%2Fconnmlt_czbr1.jpg
&description = CONNECTION%20MESA%20PARA%20LAPTOP
(Note: the URL you gave seems not to be active any more, so I grabbed another product from the site.)
Can anyone help me to solve my issue regarding the image downloading function? The situation goes like this: actually I wanna download a gantt chart image from a site that generates some string url as the image! not even http://www.example.com/img/image.png but something like http://www.example.com/img/index.php?=task&d=&Work=0...
Disregarding what language or environment you are working in, simply using the full URL with all the GET variables in place will provide you with the image.
It should not matter.
Judging from your comments below, your code is not working because you are using PHP's htmlspecialchars function.
Htmlspecialchars will turn symbols that you cannot represent in HTML output simply by adding them to the source of an html document (such as &, < and >) into identifiers that will let the browser know what kind of character to render.
for instance the ampersand (&) could be rendered by & the HtmlSpecialChars function does this for you.
When your backend code is outputting parts of html source that aren't visible to the user, such as the source of an image in this case, you do not want to use that function.
It will invalidate the URL by replacing all the & instances in the url by &
Simply do this:
<?php print($url); ?>