Twitter Helper with webmatrix issue. Displays blank page - asp.net

I'm attempting to teach myself ASP.Net and I've decided to start with web pages so I'm going through the tutorial here
The problem I'm running into is that I can't get the Twitter helper to work. I just get a blank page and can't figure out what the issue is. I have checked to make sure the Twitter helper is installed and intellsense recognizes the TwitterGoodie methods. Here is my code...
#{
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>twittertest</title>
</head>
<body>
<div>
#TwitterGoodies.Search("webmatrix")
</div>
</body>
</html>

The package referenced in the article you linked to uses version 1.0 of the Twitter API which was deprecated in June 2013. Hence nothing appears on your page. If you want a Twitter widget to appear on a page, go and get one directly from them: https://twitter.com/settings/widgets/new

Related

Asp.net Core Razor RenderPage doesn't work in _layout.cshtml

I'm reading this tutorial(https://learn.microsoft.com/en-us/aspnet/web-pages/overview/ui-layouts-and-themes/3-creating-a-consistent-look) and trying to add header and footer into layout file.
But Visual Studio is giving an error when I build the project.
<!DOCTYPE html>
<html>
<head>
<title>Structured Content </title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
#RenderPage("~/Shared/_Header.cshtml")
<div id="main">
#RenderBody()
</div>
<div id="footer">
© 2012 Contoso Pharmaceuticals. All rights reserved.
</div>
</body>
</html>
Error message:
Error (active) CS0103 The name 'RenderPage' does not exist in the current context c:\apps\Pages\Shared_Layout1.cshtml 8
If you are using .Net Core, while following an old tutorial you'll eventually end up scratching your head. Please note, that the tutorial you are using is referring to Asp.Net Web Pages, which was a nice technology released more then 10 years ago. I know it can get confusing, but nowadays verify, that these tutorials refer to at least .net core 3.1 and upwards. .Net 7 (now again without core) is about to be shipped.
You can use the Partial Tag Helper to render your partial:
<partial name="~/Shared/_Header.cshtml" />
When using an Html-Helper, it is considered best practices to use the async Html.PartialAsync method, though (The tag helper above is already ansynchronous):
#await Html.PartialAsync("~/Shared/_Header.cshtml")
Feel free to have a deeper look into the docs:
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-6.0
If you are looking for a more up-to-date tutorial please refer to https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-6.0&tabs=visual-studio
I think the solution is using RenderPartial.
#{
await Html.RenderPartialAsync("_Header");
}

OG tags not working with react-helmet and Netlify

I cannot for the life of me figure this out. The following site is hosted on Netlify and prerendering is enabled. When inspecting the page, all of the OG tags are correct. These tags are injected using react-helmet.
https://browniepoints.africa/opportunities/volunteer-at-a-soup-kitchen-every-week-on-thursdays
When scraping the above URL on the Facebook debugger, it responds with:
The following required properties are missing: og:url, og:type, og:title, og:image, og:description, fb:app_id
The only one of those errors/warnings that should be there is the app_id, which I don't care about.
I've waited well over 48 hours for caches to clear, I've tried scraping with query strings appended to the URL, and the images have absolute URLs. But not even the description tag is pulling through.
Can somebody that uses react-helmet and Netlify please shed some definitive light onto this problem?
This is related to a known prerendering issue.
My fix was to remove the <!DOCTYPE html> declaration from the index.html file as a temporary workaround until the above issue is resolved.
While I can't tell you exactly why. your SSR is not working correctly. Go to Chrome DevTools and click the 3 vertical dots next to Console:
Select Networking Conditions, then uncheck Select Automatically and enter Googlebot/2.1 (+http://www.google.com/bot.html):
Now refresh the page and notice that all you see on the site is some plaintext saying "html" and even your javascript bundle is missing. This is what your html looks like:
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="fragment" content="!">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Brownie Points</title>
<link href="/static/css/2.3bf0f3c5.chunk.css" rel="stylesheet">
</head>
<body><noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Note that Netlify SSR is in Beta but I personally didn't have those issues with it. Have you done any other steps other than enable it? I have tested it to be working with a CRA generated app before.

xhtml link can't be opened and file was not found

Hey guys I am new to web languages. I was just trying out the link syntax of xhtml and everything appears smooth until I clicked on the link and it tells me that my file is not found, either moved or deleted. It's really basic however I checked word for word that the syntax is correct, and nothing on the internet answers it hope someone could help.
<!doctype html>
<html>
<head>
<title>This is title</title>
</head>
<body>
click me.
<br>
This will link to the second page
</body>
</html>
Edited Links
click me. <br><a>
<href="second.html">This will link to the second page</a>

The <html> tag is automatically generated and I want <html lang="en">

I want to use any javascript or jquery which on page load will add attribute LANG=EN to the web page. I tried using $('html').attr('name', 'value'); so still i am facing the same issue.
Using jQuery to change the doc type and <html> tag is the absolutely the worst way to do what you need. jQuery rewrites the DOM, not real page source. jQuery is not intended to change such things as <html> tags.
You need to edit the theme you are using. The <html> is being output by your header.php file of the theme. If you really want <html lang="en">, edit header.php.
And read What is lang attribute of the <html> tag used for?

Advanced iframe solution from external source

Oki, I got my head on the table here.
I'm trying to get contents from another page, and interact with it. Using some kind of advanced iframe solution.
Up until now I've been using the ugly iframe solution, you can see the results here :
http://www.mosfellsbaer.is/stjornkerfi/stjornkerfi/fundargerdir/
Please try to interact with it to see how ugly this is.
Ok..
I found another page that uses the same system as we do, but it looks a lot better.
It's an iframe, but when looking at the source code, I dont see any iframe embed code or anything that points to that it's an iframe. Here is the page :
http://www.kopavogur.is/stjornsyslan/fundargerdir/searchmeetings.aspx
But I know this is some kind of an iframe.
Their way is a bit better because they can use their own css and such.
Somehow they get the contents from the searchmeetings.aspx and post it to their page
How the h... are they doing this ?
I'm kind of new at this here
Thanks in advance
It's not an iframe... Looks like they're doing something like this: How to display an ASPX in another ASPX's DIV dynamically at runtime?
It's an ASP page, and the inserted document has a few clues telling us that it's a Microsoft generated page as well:
<div class="boxbody">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Leit í fundargerðum</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link href="css/fonts.css" rel="stylesheet" type="text/css">
</HEAD>
<body>

Resources