Error processing resource: An invalid character was found in text content - html

I am getting the below error when trying to view a web page, can someone please let me know the cause and solution to resolve this error:
The XML page cannot be displayed
Cannot view XML input using style sheet.
Please correct the error and then click the Refresh button, or try
again later.
An invalid character was found in text content. Error processing
resource 'http://xxxxxxxxxxx/Auth/Ncoa/pdfviewer.asp...
%
Code behind:
public class Ncoa_PdfViewer : Page
{
protected HtmlForm _pdfViewer;
protected void Page_Load(object sender, EventArgs e)
{
ExpressBill.XNet.UI.Services.Ncoa ncoa = new ExpressBill.XNet.UI.Services.Ncoa("NcoaServiceUri");
((WebClientProtocol)ncoa).Timeout = -1;
int clientId = int.Parse(this.Request.QueryString["clientid"]);
byte[] pdfPackage;
if (clientId == 0)
{
NcoaOwner owner = NcoaOwner.GetOwnerForPdfDisplay(this.Session);
NcoaAgent[] agents = NcoaAgent.GetAgentsForPdfDisplay(this.Session);
if (owner == null)
owner = new NcoaOwner();
if (agents == null)
agents = new NcoaAgent[0];
pdfPackage = ncoa.GetPDFPackage(owner, agents);
}
else
pdfPackage = ncoa.GetPDFPackage(clientId);
this.Response.Clear();
this.Response.ContentType = "application/pdf";
this.Response.AddHeader("content-length", Convert.ToString(pdfPackage.Length));
this.Response.BinaryWrite(pdfPackage);
this.Response.Flush();
this.Response.End();
}
}
Design markup:
<%# Page Language="C#" AutoEventWireup="true" Inherits="ExpressBill.XNet.UI.Ncoa.Ncoa_PdfViewer" Codebehind="PdfViewer.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pdf Viewer</title>
</head>
<body>
<form id="_pdfViewer" runat="server">
<div>
</div>
</form>

I think the problem is html can't read c# or whatever that is. If you want to make a website you can use css, js, html, svg, or php, but not c#. If html can read c# the computer will be very easy to hack. html, js, css, svg, php are different programming languages and they are very easy to learn. If you want more detail you can search w3school or watch youtube to get started.

Related

Thymeleaf Content-Type is being ignored in HTML Email (not rendered as HTML)

I'm developing a RESTful API with Spring Boot as backend and an Angular 9 frontend. Upon user registration, a verification email is sent, in which the user needs to click on a link to verify their account. Functionally, all is set and working. However, the HTML is never rendered despite having Content-Type set to 'text/html' and charset to UTF-8. I'm using Thymeleaf to generate the HTML:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
</head>
<body>
<header>TooManyThoughts</header>
<section>
<p th:text="#{registration.mail.greeting(${#messages.msg('mail.greeting.title.' + user.personalData.title.representation, user.personalData.firstName, user.personalData.lastName)})}"></p>
<p th:text="#{registration.mail.preamble}"></p>
<p>
<a th:text="#{registration.mail.link}"
th:href="#{http://localhost:8081/auth/register/email/verify/{id}/{key}(id = ${user.id}, key = ${user.emailValidationKey}, send='auth,login', verified='email')}"></a>
</p>
<p>
<span th:text="#{registration.mail.clue01(${user.credentials.username})}"></span>
<span th:text="#{registration.mail.clue02}"></span>
</p>
<p th:text="#{registration.mail.catchphrase}"></p>
<p th:text="#{registration.mail.goodbye}"></p>
<p>
<span th:text="#{registration.mail.signature01}"></span>
<br>
<span th:text="#{registration.mail.signature02}"></span>
</p>
</section>
<footer></footer>
</body>
At the time of writing, all frameworks used are in their latest versions. Currently, I'm sending the email to my personal gmail account. When googling the issue, I've found some rendering issues with gmail, but they've all been old and from around 2011 or so. The only other posts and entries I could find were about setting Content-Type and charset properly, which in my opinion I've done.
I'm kinda stuck here since two days with what I believe should be a very basic issue, so any help is highly appreciated.
Thanks to Andrew's hint on using setContent() instead of setText() for javax.mail.Message, I realized that I've never actually set the content type of my email anywhere in the code. I'm not using javax.mail but springframework.mail.javamail, so I had to look for a solution and I found it here. The working code now looks like this:
public EmailVerificationModel sendMail(final EmailVerificationModel model) {
final MimeMessagePreparator msgPreparator = mimeMessage -> {
final MimeMessageHelper msgHelper = new MimeMessageHelper(mimeMessage, "UTF-8");
msgHelper.setFrom("petesideburner#gmail.com");
msgHelper.setTo(model.getCredentials().getEmail());
msgHelper.setSubject(this.mailBuilder.subject(model));
msgHelper.setText(this.mailBuilder.build(model), true);
};
this.mailSender.send(msgPreparator);
return this.verificationMailSent(model);
}
All that I had to do was to pass true as 2nd argument to Spring's MimeMessageHelper.setText() method. The hidden quirks of method signatures. Personally, I prefer more distinct names for methods and variables, and so for better readability of my code I've changed it to:
public EmailVerificationModel sendHtmlMail(final EmailVerificationModel model) {
final boolean html = true;
final MimeMessagePreparator msgPreparator = mimeMessage -> {
[...]
msgHelper.setText(this.mailBuilder.build(model), html);
};
this.mailSender.send(msgPreparator);
return this.verificationMailSent(model);
}

SSRS report server Data issue

I have deployed SSRS report on Production environment. When 3 or more user run the same report on production then report server load other user requested data.
For Example-
Below 3 request-
User A requested Report X with Paremeter A
User B requested Report X with Paremeter B
User C requested Report X with Paremeter C
Output from SSRS server -
User A requested Report X with Paremeter A
User B requested Report X with Paremeter A
User C requested Report X with Paremeter C
Note- This problem occur when all the users request report in same time.
We had same issue, if you are using ReportViewerForMVC from NuGet Package manager which is third party control may cause problem, follow below points
we will re-use code from ReportViewerForMvc and modify as per our need
1
Install-package ReportViewerForMvc and press enter. After few minutes the package will be installed
2
This installation will add to the project: 2 assemblies (Microsoft.ReportViewer.WebForms & ReportViewerForMvc)to references an .aspx page (ReportViewerWebForm.aspx) and httphandlers settings in the web.config file.
Note: the .aspx page added does not have a .cs file.
You can now use this .aspx page and code everything in controller, but I am using a slightly different path for code reusability and consistency)
Add a new folder ‘Reports” to the project, and then add a new webform .aspx page (ReportTemplate.aspx to the Reports folder
3
Copy the contents (as shown in fig) from ReportViewerWebForm.aspx and replace the content of ReportTemplate.aspx with this.
Note: Please do not copy #page directive, copy only the highlighted section.
4
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<!doctype html>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="scriptManagerReport" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer runat ="server" ShowPrintButton="false" Width="99.9%" Height="100%" AsyncRendering="true" ZoomMode="Percent" KeepSessionAlive="true" id="rvSiteMapping" SizeToReportContent="false" >
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
5
The ReportTemplate.aspx will change to this
6
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="ReportTemplate.aspx.cs" Inherits="ASPNETMVC_SSRS_Demo.Reports.ReportTemplate" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<!doctype html>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="scriptManagerReport" runat="server">
<Scripts>
<asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" />
</Scripts>
</asp:ScriptManager>
<rsweb:ReportViewer runat ="server" ShowPrintButton="false" Width="99.9%" Height="100%" AsyncRendering="true" ZoomMode="Percent" KeepSessionAlive="true" id="rvSiteMapping" SizeToReportContent="false" >
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
7
Next delete the below scripts tag from ReportTemplate.aspx page
<Scripts>
<asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" />
</Scripts>
8
Add additional attributes to the ReportViewercontrol as below
<rsweb:ReportViewer id="rvSiteMapping"runat ="server"ShowPrintButton="false"Width="99.9%"Height="100%"AsyncRendering="true"ZoomMode="Percent"KeepSessionAlive="true"SizeToReportContent="false"></rsweb:ReportViewer>
9
Now open ReportTemplate.aspx.cs file and add below code to the Page_load event, you need to the SSRS Server URL and SSRS report Folder path.
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPNETMVC_SSRS_Demo.Reports
{
public partial class ReportTemplate : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
String reportFolder = System.Configuration.ConfigurationManager
.AppSettings["SSRSReportsFolder"].ToString();
rvSiteMapping.Height =
Unit.Pixel(Convert.ToInt32(Request["Height"]) - 58);
rvSiteMapping.ProcessingMode =
Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rvSiteMapping.ServerReport.ReportServerUrl = new Uri("SSRS
URL"); // Add the Reporting Server URL
rvSiteMapping.ServerReport.ReportPath =
String.Format("/{0}/{1}", reportFolder, Request["ReportName"].ToString());
rvSiteMapping.ServerReport.Refresh();
}
catch (Exception ex)
{
}
}
}
}
}
10
Add the SSRSReportFolder path to the app settings in the web.config file.
<add key="SSRSReportsFolder" value="BIC_Reports"/>
11
Next, create an entity class ReportInfo.cs under Models folder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ASPNETMVC_SSRS_Demo.Models
{
public class ReportInfo
{
public int ReportId { get; set; }
public string ReportName { get; set; }
public string ReportDescription { get; set; }
public string ReportURL { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public string ReportSummary { get; set; }
}
}
12
Next, we will add code to the Controller and the View Pages. There is no
change to the HomeController.cs. Add the following code to Home/Index view
page.
#{
ViewBag.Title = "Index";
}
<h2>Reports List</h2>
<a id="ReportUrl_Performance" href="#Url.Action("ReportTemplate", "Report", new { ReportName = "Performance", ReportDescription = "Performance Report", Width = 100, Height = 650 })">
Performance Report</a>
13 Next
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ASPNETMVC_SSRS_Demo.Models;
namespace ASPNETMVC_SSRS_Demo.Controllers
{
public class ReportController : Controller
{
//
// GET: /Report/
public ActionResult ReportTemplate(string ReportName, string
ReportDescription, int Width, int Height)
{
var rptInfo = new ReportInfo
{
ReportName = ReportName,
ReportDescription = ReportDescription,
ReportURL = String.Format("../../Reports/ReportTemplate.aspx?
ReportName={0}&Height={1}", ReportName, Height),
Width = Width,
Height = Height
};
return View(rptInfo);
}
}
}
14
Final Step is to open the ReportTemplate view page under Report and add the following code.
#model ASPNETMVC_SSRS_Demo.Models.ReportInfo
<H1>
#Model.ReportDescription
</H1>
<iframe id="frmReport" src="#Model.ReportURL" frameborder="0" style="#String.Format("width:{0}%; height: {1}px;", Model.Width, Model.Height)" scrolling="no">
</iframe>

How to determine if i have implemented d3 correctly?

Forgive me for this beginner question. I am trying to implement d3 on a HTML page, which is displayed in a JScrollPane in a Swing project. Am following the tutorial # http://alignedleft.com/tutorials/d3/adding-elements.
As I type code, I do not see template proposals after every dot. Would not like to run it on a temp server at the moment. The new paragraph that's supposedly generated when I run the application does not appear.
Does that mean that my source link to d3 is implemented wrongly & hence no template proposals? Is there any way to determine if elements from the DOM are selected correctly? Elements not embedded within the script is shown correctly however. Please advise.
Code:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="utf-8">
<title>D3 test</title>
<script type = "text / javascript" src="d3/d3.v3.js"></script>
</head>
<body>
<script type = "text / javascript" src="d3.js">
d3.select("body").append("p").text("New paragraph!!!");
</script>
</body>
</html>
the other class:
jfxpanel = new JFXPanel();
Platform.runLater(new Runnable() {
#Override
public void run() {
try {
WebView browser = new WebView();
WebEngine engine = browser.getEngine();
//String url = "http://www.hotmail.com";
File f = new File ("src/d3/index.html"); //display local html, instead of external webpage
System.out.println("current directory: " + f.getAbsolutePath());
String url = f.toURI().toURL().toString();
engine.load(url);
Scene scene = new Scene(browser);
jfxpanel.setScene(scene);
}
catch (Exception e){
while (e != null) {
e.printStackTrace();
}
}
}
});
spVisual = new JScrollPane(jfxpanel);
//spVisual.setEnabled(false);
spVisual.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
spVisual.setSize(800, 420);
spVisual.setLocation(100, 140);
spVisual.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
//spVisual.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
spVisual.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
spVisual.getViewport().setViewPosition(new java.awt.Point(0, 0));
}
});
add (spVisual);
Don't know anything about embedding html in swing but I do know that, using src and inline javascript on the same tag is not a good idea.
Also that TEST is within a <script> tag, so it'll be executed as javascript and it's not valid.
Finally, you assuming d3 is loading, your selector, append and text are fine.
Perhaps try:
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="utf-8">
<title>D3 test</title>
<script src="d3/d3.v3.js"></script>
</head>
<body>
<script>
d3.select("body").append("p").text("New paragraph!!!");
</script>
TEST
</body>
</html>

Ooyala player setembedcode

I am trying to implement Ooyala's player in my code and I was told that if I wanted to use buttons to switch the content of the video player then I should use the setEmbedCode function but the examples they have on their site aren't very clear.
What I want to have happen is to simply have a link that when clicked will change the video to a different URL/embed code. I've tried using the 'setQueryStringParameters'
document.getElementById('video-player'+pageNum).setQueryStringParameters({embedCode:videoURL})
All I get with that is a:
'is not a function message.'
var url = 'http://player.ooyala.com/player.js?embedCode='+videoURL+'&targetReplaceId=video-player'+pageNum+'';
var tempScript = document.createElement('script');
tempScript.type = 'text/javascript';
tempScript.src = url;
When I call this it creates the video player just fine, but I'm not sure how to change the embed code once it's created.
Check this sample code from ooyala site. "SwitchMovie" will play different video with different embedcode.
http://demo.ooyala.com/product-demos/playerScripting-demo.html
document.getElementById('player').setQueryStringParameters({embedCode:'8wNTqa-6MkpEB1c7fNGOpoSJytLptmm9',hide:'share,fullscreen'})
UPDATE:
The following code is working perfect for me. Try it, as I mentioned in my comments below you need to have a callback function if you need to interface with the player.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Swap Video</title>
</head>
<body>
<script src="http://player.ooyala.com/player.js?callback=receiveOoyalaEvent&playerId=player&width=480&height=360&embedCode=llMDQ6rMWxVWbvdxs2yduVEtSrNCJUk1&version=2"></script>
<script>
function receiveOoyalaEvent(playerId, eventName, eventArgs) {
}
</script>
<br><br>
<button onclick="document.getElementById('player').setQueryStringParameters({embedCode:'8wNTqa-6MkpEB1c7fNGOpoSJytLptmm9',hide:'share,fullscreen'})">Switch Movie</button>
</body>
</html>

How to make an iframe which displays the parent page

I want to display an iframe in a .aspx page, and the iframes source should be the same page.
I need to use a relative uri.
What value should I give the 'src' attribute?
I realise this is a little unusual - the page will be displayed in different states depending on parameters passed in, so the iframe won't be displayed within itself.
If you do this you will get an endless loop... the processsing will "never end". maybe thats why it is white? it is really processing pages..
- is that what you want ? if you for example want just 2-3 pages in depth, you can youse querystring and for example disable the iframe when the querystrings are incremented to 3.
MyPage.aspx?depth=1 --MyPage.aspx?depth=2 --MyPage.aspx?depth=3 etc
The literal relative path should work. IE: MyPage.aspx
Here is an ASP.NET Example...
Seemed to work fine for me with the following...
Markup:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<iframe runat="server" id="myFrame" src="Default.aspx?message=Hello%20World"></iframe>
<div id="myDiv" runat="server"></div>
</div>
</form>
</body>
</html>
Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string message = Request.QueryString["message"];
if (null != message)
{
myDiv.InnerText = message;
myFrame.Visible = false;
}
else
{
myDiv.Visible = false;
}
}
}
}
The short answer is src="localfilename.aspx" within the iframe tag. The web standard, loosely applied, says anything not proceeded by a '/' is relative to the location of the current page. Sometimes src="" might even work for substituting the current file name (at the browser level)