Full html page as startpage in MVC application - asp.net-mvc

Fairly new to MVC, and on my first schoolbased internship!
Im creating a mvc project and they are asking me to set an already finished html page as
"Home page" for the project. This homepage will "if links are clicked" redirect to the mvc
project and what i am creating.
Are there any particular guidelines or ways of how to do this in an pure "MVC correct" fashion?
Getting my info from wherever it is possible, so answers would be very appreciated!

You should first create some layout page like this example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Page</title>
</head>
<body>
#RenderBody()
</body>
</html>
In view associated with Home controller Index action place your already finished html code. Remove from there tags already existing in layout.
And after it modify all links url which referencing to your project actions to something like this:
<a href='#Url.Action("Home","SomeAction")'>Link</a>

I presume you use Visual Studio for that, right?
Open it, go to File > New Project
Select ASP.NET MVC 3 Web Application (here you can have many versions of MVC available)
Visual Studio will create a sample application with everything created for you. Study it.

Related

pyscript error with WordPress integration

Hi Goodies i have an issue in pyscript
issue : when i paste the below pyscript code in my WordPress post as an html and press preview it just simply popups to dawnload the pyodide file instead of showing the hello world message in the code below. Please someone can clear that to me why this is happening.
thanks regards
<!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>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
<py-script> print('Now you can!') </py-script>|
</body>
</html>
the output screenshots from the browser where i get this happening.
(1) From WordPress
this is once i write the code in real time wordpress post as an html
this is what i got once i click on preview
(2) Samething is happening in vscode live server instead of the showing the message hello world it just popup my dawnloader idm to dawnload a pyodide file.
this is the code in vscode with the live server
this is what i got once i run with the live server in vscode
i need to run a small python code in my WordPress post when someone visit my website and in that post once he requests some calculation so the python code should be responsible to do some calculations and show that to the user.
any suggestions please
From the logo on the popup messages you're getting in both cases, it looks like this is behavior caused by having [https://www.internetdownloadmanager.com/](Internet Download Manager) (IDM) installed.
When the Pyodide runtime loads, it fetches certain additional files from the web, including pyodide_py.tar (the compressed Python API files the Pyodide Python API, as well as any additional packages specified in <py-config>. If IDM is configured to interrupt fetching these necessary files, Pyodide will fail to load and/or execute.
You may be able to whitelist (allow) IDM to automatically download these files, but that's beyond my knowledge of that particular plugin.
For more discussion, here's a similar issue on the PyScript GitHub.

Strapi CMS not loading index.html correct path (undefined)

Im using Strapi 3.6.8 and i came cross a problem i cant understand with loading the Admin panel.
the CMS status page is working perfect and the API is responding with no problem, but when i try to open the Admin panel i get blank page (white page) and in the page source ican see that there are two files that get 404 error (not found).
The files are: runtime-main.XXXXXXX.js, main.xxxxxxx.chunk.js.
The probplem is clear - the files path is wrong as you can see in the files source:
<!doctype html>
<html lang="en">
<head>
<!-- The first thing in any HTML file should be the charset -->
<meta charset="utf-8">
<!-- Make the page mobile compatible -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<title>Strapi Admin</title>
</head>
<body>
<!-- The app hooks into this div -->
<div id="app"></div>
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
<script type="text/javascript" src="/undefined/cms/undefined/admin/runtime~main.1727abc3.js"></script><script type="text/javascript" src="/undefined/cms/undefined/admin/main.be8fb29b.chunk.js"></script></body>
</html>
unforthantly, i wasn;t able to figure it by myself, i tried the following:
Checked ENV files
Cleared yarn/npm lock files and node-module folder (and reinstalled)
Update packages
Build and run locally using docker (instead of just runing the server locally)
none of the things i tried is working, im sure it's something really small and stupid to fix. it worked perfeclty until somepoint, but i cant findout what was changed.
Thanks.

Is it possible to add lazy loading to ASP.NET MVC + React.js application?

I have ASP.NET application. Each View looks like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="bundle.js"></script>
</head>
<body>
<div id="main"></div>
</body>
</html>
where bundle.jsis built using webpack from React.js code. Rounting is implemented using Controllers. Is it possible to add lazy-loading to this application?
I've found that React 16.6+ supports component-based code-splitting and lazy-loading has been added via React.lazy() and React.Suspense. But the features are not available for server-side rendering. Is it possible to say that the described application is server-side rendering?

Github website hosting, handling incorrect subpages

I have hosted a simple singlepage HTML/CSS website on github. I wanted to redirect incorrect subpages (ie mysite.com/m) to redirect to the homepage (mysite.com) as the default route. Can this be achieved on a static site on github?
You can create a /m/index.html file containing :
<!DOCTYPE html>
<meta charset=utf-8>
<title>Redirecting...</title>
<link rel=canonical href="/index.html">
<meta http-equiv=refresh content="0; url=/index.html">
<h1>Redirecting...</h1>
Click here if you are not redirected.
<script>location='/index.html'</script>

Using WebMatrix and Razor

I am using WebMatrix to edit my web page. After clicking on the Run button, I can see the time being displayed, but when launching the page from the desktop I see the source code [#m_date.ToString()].
--snip--
#{var m_date = DateTime.Now; }
<!DOCTYPE html>
<head>
....
</head>
<body>
...
<p style="text-align: center">#m_date.ToString()</p>
...
</body
What am I doing wrong?
Thanks in advance.
Razor is a server-side technology. This means that your page needs to be processed by a server. This server turns the mix of html and razor code, into plain Html. This Html can then be rendered by your browser.
When you open a .cshtml directly in your browser, the razor code is not processed, and is displayed as the contents.
Webmatrix uses a server (IIS express most probably in your case) to launch your page. When you hit run it starts your browser and you go to url like localhost:12345 with the rendered (already processed) page.
If you have saved this page to your desktop it will be either html or cshtml depending on how you saved it. Then clicking on it does not process it, but rather you ask the browser to show the contents.
Here is an intro to Webmatrix to understand how it works and what it does when you do trivial things like this one.

Resources