Error posting images from web pages using #Url.Content in MVC - html

I'm trying to allow users to edit my database by adding images from websites (posting the URL links into a field using the edit view), when trying to deploy my MVC project, I got an error that says a different row in my table cannot be null, it wasn't null, but when I removed this line of code that would present the image on the page, the error went away:
<img src="#Url.Content(item.Picture)" height="100" />
This is the line of code the error pointed out:
#Html.DisplayFor(m => item.Founder)

Related

Error with generate and downloading MVC view to PDF function (Itext - System IO.IO this document has no pages)

I'm new to ASP.NET MVC and not that good with coding. I'm trying to download my returned list from view as a PDF document
The exact error I get is:
System.IO.IOException
HResult=0x80131620
The document has no pages.
Source=itextsharp
StackTrace:
at iTextSharp.text.pdf.PdfPages.WritePageTree()
at iTextSharp.text.pdf.PdfWriter.Close()
at iTextSharp.text.pdf.PdfDocument.Close()
at iTextSharp.text.Document.Close()
My controller with function
My view html
Your problem is in your jquery and your html, you are not passing any values into your div, your table is also not in your div. Thus jquery is pulling nothing, that means that your stream is getting no bytes.

Thymeleaf email image not displayed

I'm using Thymeleaf with Spring Boot.
I'm trying to send a mail with a html template.
The mail is ok, the variable thymeleaf in the template are replace it's perfect, but, my only one problem is that the image are not displayed. It's just like if the image doen't exist.
The html template and the image ( Picture.png ) are on the same folder.
In the template I have try these multiples tries :
<img src="Picture.png" />
<img src="#{Picture.png}" />
<img th:src="|cid:${imageName}|" /> // by passing the "Picture.png" in the imageName variable
<img th:src="#{Picture.png}" />
But nothing is working, I need help thanks !
I answer my own question because I suceed to resolve the problem :
Just put like that <img src="cid:imageName"/> in the html file
Checkout the Thymeleaf's documentation especially the part for context-relative and server-relative url patterns.
If your project root directory is called myapp and you deploy it into a Tomcat server, your application will probably be accessible as http://localhost:8080/myapp, and myapp will be the context name.
So assuming the folder containing both the image and the html is located at:
myapp/resource/assets/(html and Picture.png exists)
the correct code to dynamically fetch the image is:
<img src="resource/assets/Picture.png" th:src="#{resource/assets/Picture.png}" />

AngularJs : two page routing won't work for changing views , status code : 404

As a newbie in Angular, i am working a tutorial : WEB DEVELOPMENT WITH_ANGULARJS AND BOOTSTRAP via "Packt".
Below is the link in plunker to check the code implementation.
At the moment i am working on the Routing Events, specificly a login form where i added 2 links to change the view from the Login form to Report.
The error i receive is when i click on these links it returns :
{ "statusCode": 404,"error": "Not Found"}
Furthermore the data binding for the "report" template won't work as well.
The version of Angular that is been used in the tutorial is AngularJs v1.3.0, however i am using v1.4.6 and no problem have been occurred so far!
While most of the similar issue posts refer to a version compatibility issue , in my case any version of Angular i used it produces the same error.
Have i done anything wrong in the script.js configuration?
The href's you are using don't include the hash and proper angular path.
Change:
Login
Report
To:
Login
Report

How to render template only when it is populated?

I have a template for picture gallery which is populated with an ajax callback.
The problem is that before the template is populated, since it is looking for an image, I get a console error that the image is not found.
<img src="{{image.url}}" alt="{{image.alt}}">
How can I render this template only once there the data is available?
You are using src which would be intially be null and hence the browser makes a request for it. ng-src fixes it
ng-src='image.url'

Error connecting to server when embedding video

While trying to embed some code on my website, I received the following error:
[Server.Reject] : (defaultRoot, defaultVHost) : Invalid application name (vod/liv e_2011_11_30_beard).
The strange thing is that it works inside the WYSIWYG editor I use, but the error occurs when the post is published or previewed.
The code I am embedding was as follows:
<embed src='http://www.nypl.org/sites/all/modules/nypl_content/jwplayer/player-licensed.swf' width='426' height='286' bgcolor='000000' allowscriptaccess='always' allowfullscreen='true' play='true' wmode='opaque' flashvars='image=http%3A%2F%2Fwww.nypl.org%2Fsites%2Fdefault%2Ffiles%2Fimages%2Fav%2F6437035995_67dc89cb40_b.jpg&file=live_2011_11_30_beard.mp4&streamer=rtmp%3A%2F%2Fflash01.nypl.org%2Fvod%2Flive_2011_11_30_beard&skin=http%3A%2F%2Fwww.nypl.org%2Fsites%2Fall%2Fmodules%2Fnypl_content%2Fjwplayer%2Fskins%2Fstormtrooper.zip&plugins=gapro-1,adtvideo%2Cviral-2&adtvideo.config=/xml/ad_config/seed&gapro.accountid=UA-1420324-3&gapro.trackstarts=true&gapro.trackpercentage=true&gapro.tracktime=true&gapro.idstring=||streamer||&viral.onpause=false&viral.oncomplete=true&viral.allowmenu=false&viral.functions=embed'></embed>