I Have the simplest web page, a line of text. When I dotnet build & dotnet run, then launch the webpage, nothing is displayed despite the code being built fine. Any ideas?
My HTML code
#page
#model WebApp.Pages.ViewActors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web App</title>
</head>
<body>
<h1>#Model.Heading</h1>
</body>
</html>
My C# class
namespace WebApp.Pages
{
public class ViewActors : PageModel
{
public String Heading { get; set; }
public void onGet()
{
Heading = "James Bond Actors";
}
}
}
So Model.heading = "James Bond Actors"
But the page source only displays,
<html lang="en"><head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web App</title>
</head>
<body>
<h1></h1>
</body></html>
With nothing displayed between
<h1></h1>
Any help would be appreciated.
I've tried basic text and that displays but not the model.heading & viewed similar questions but no help. Thanks
onGet() should be OnGet() with a capital O.
Related
have a problem with Live Server Updating Index.html ...
It's works when i doing manually save... working with big project, and manually update every time page is too stupid deal
in Index.html I using Iframe to navigation.html ..
pay attention when i updating navigation.html it's working , updating ...
but when i trying to update index.html .. unfortunately ...
Here Is :::
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Pam dasd adsadsa dasdsa </h1>
<iframe 1 src ="navigation.html" linkTarget = "iframe2">
<iframe2>
</body>
</html>
navigation.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li>agent 1 link</li>
<li>agent 2 link</li>
<li>agent 3 link</li>
<li>agent 4 link</li>
</ul>
</body>
</html>
PS : Help -> Toggle Developer Tool , showing no errors, all working ok. i mean : [Extension Host] Change detected
Here is Repo:::
enter image description here
Maybe that it extension bug ? :)
PS:::
!!!Attention!!!
Without iframe tag Index.html .. Live is working well .
But i need iframe.
Is your index.html inside of a folder preceded by a period?
Does your domain look like this? http://127.0.0.1:5500/.folder/index.html
I m building a Wen Application using Razor page (c#). So in my "_Layout.cshtml page" I m build this code:
<!DOCTYPE html>
<html style="height:110%;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Title</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../Scripts/jquery.min.js"></script>
<link href="../Content/jquery-ui.css" rel="stylesheet">
<script src="../Scripts/jquery-ui.min.js"></script>
</head>
<body style="width:100%;height:100%;">
<div class="container body-content">
#RenderBody()
</div>
</body>
</html>
So In my local pc, if I try to open Index Page, I can see this if I try to see Code of HTML page:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eresult srl</title>
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.8.3.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../Scripts/jquery.min.js"></script>
<link href="../Content/jquery-ui.css" rel="stylesheet">
<script src="../Scripts/jquery-ui.min.js"></script>
</head>
To see the index page on my local pc, I use this link "http:/localhost:9094/Pagina.aspx"
Now if I try to install this application on the server side, I have some problem of Graphic.
This is the url that I use: "http://url:9094/Questionario/Pagina.aspx"
This is the code that I can see if I see code of HTML page.
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eresult srl</title>
<link href="/Questionario/Content/css?v=5h6Wc7kfOUsqxEEmYLsFbm8C9NAaEGNbzkeznwX1XR41" rel="stylesheet"/>
<script src="/Questionario/bundles/modernizr?v=inCVuEFe6J4Q07A0AcRsbJic_UE5MwpRMNGcOtk94TE1"></script>
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>-->
<!--<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />-->
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../Scripts/jquery.min.js"></script>
<link href="../Content/jquery-ui.css" rel="stylesheet">
<script src="../Scripts/jquery-ui.min.js"></script>
</head>
As you can see on server side the system cannot load css and js file correctly.
You have to use relative paths all over your app especially when you deploy it to the server (like IIS):
~ won't work within static html code, therefore use:
<script src="#Url.Content("~/Scripts/jquery.min.js")"></script>
<link href="#Url.Content("~/Content/jquery-ui.css")" rel="stylesheet">
<script src="#Url.Content("~/Scripts/jquery-ui.min.js")"></script>
I am trying to convert my simple html document into image. I am using NReco.ImageGenerator for this.
But it does not show included image and styles
I am using Windows 10
Here is my code
var html = File.ReadAllText("main.html");
var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();
var jpegBytes = htmlToImageConv.GenerateImage(html, "png");
File.WriteAllBytes("image.png", jpegBytes);
It is html document
In browser
My code's output
The problem is that NReco will be unable to find the file of the image in the html.
Two possible solutions that immediately come to mind.
Host the image on a valid URL or use an inline image using base64 encoding in the html.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<link href="style.css" rel="stylesheet">
</head>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANwAAADcAQMAAAAhlF3CAAAABlBMVEX///8AAABVwtN+AAABCUlEQVRYhe3XMQ6DMAwF0I8YMuYIHIWjNUfjKByBkQGR2okTUFXaMPMttbR5TJadOIglAgB9YiwrC4iKEzT6GAb5PzvBNa3gRTT0mqn+lL61k8dOvIeSW8ARr1EqkHgfa/NuwCCN+72zH4wlFPP2VlaI//EUWn2X8Vy0TPXylasvTm7HuHR6IhAbMO1kApu9qc3rd8stMW9vegjE2p976tFAbECN4LXyZPwYLLfEA6UVc/rqhAHpT6s+4l+sMcQDbXsjhnIAaLFZ5UnDdulDbMEpJdaumLP+dvY20fB0xTzS54l3MZ8QUeeRMU//RHymr04YxFYszVvnW8svMZYbQI56CcepP4m/8Q15PctBEVIBfQAAAABJRU5ErkJggg==" />
<p class="text">Some text</p>
</body>
</html>
or use a local file url like file:///
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<link href="style.css" rel="stylesheet">
</head>
<body>
<img src="file:///C:/Users/jdarling/Desktop/SO_20190718/images/back.png" />
<p class="text">Some text</p>
</body>
</html>
I'm new to adding meta tags from behind code, but if SEO Meta Tags were added from behind code,from a database for example, will they work as they were added in the markup from the beginning?
If so, where should I create them? Page_PreRender, Page_Init,..etc.
Thanks in advance.
Server will render your page to client(browser, search engine crawler)
It is better add it to your page's template, your Razor file or aspx file.
if you do want to add it to you page. you could add it to Page_Load, Page_Render or Page_Pre_Render
E.g.
I will add below to my _Layout.cshtml file or similar code to master page template.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
#if (Page.NeedAdditionMeta)
{
<meta name="m1" content="xxx" />
<meta name="m2" content="yyy" />
<meta name="m2" content="zzz" />
}
I have a WPF with a browser control that points to a local HTML file.
I have my .html and .css files in a folder labelled WebResources but it seems no matter how I link the stylesheet in the index.html file the styling doesn't show.
My Solutions Explorer
Solution MyProject
-- MyProject
---- Properties
---- References
---- WebResources
---- Index.html
---- Style.css
Index.html
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="WebResources\Style.css" />
<!-- Also Tried "<link rel="stylesheet" href="Full\Path\To\Style.css" /> -->
</head>
<body>
<div class="container">
<h1>This should be very big</h1>
</div>
</body>
</html>
Style.css
h1 {
font-size: 10em;
}
If index.html and Style.css are in the same folder you should use:
<link rel="stylesheet" href="Style.css" />
I just tried with a test app and it works well.
Let me know.
Have you tried forward-slashes (/)? html pages usually reference other resources with these rather than Windows-style back-slashes