Friday 23 June 2023

How to Setup MVC React.NET Project



                


References:

Tutorial (ASP.NET 4.x)

https://reactjs.net/
https://reactjs.net/tutorials/aspnet4.html

Step 1: Creating a Basic Project Solution

Minimum Requirements

  • .Net 4.6.1
  • Visual Studio 2017 or later version. (VS 2019 recommended) §NuGet Package Manager.
  • Node JS

Project Template: ASP.Net Web Application (With MVC Compatibility)

  • Choose Language: C#
  • Choose .Net version: 4.6.1
  • Choose an Empty Project Template.
  • Add core reference MVC.












The Project Solution




Remove Unwanted Packages and Project resources from the solution, then add the ‘themes’ folder, ‘js’ folder, etc.




Step 2: Install and configure the required NuGet packages

1. React.Web.Mvc4, version 5.2.12








2. JavaScriptEngineSwitcher.V8




To use V8, add the following packages:JavaScriptEngineSwitcher.V8

JavaScriptEngineSwitcher.V8.Native.win-x64

ReactConfig.cs will be automatically generated for you. Update it to register a JS engine.

using JavaScriptEngineSwitcher.Core;

using JavaScriptEngineSwitcher.V8;


JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;

JsEngineSwitcher.Current.EngineFactories.AddV8();





Note: To fix the compiler issue Install the Fix package.
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.BinFix

Step 3: Install Node Js

Download Link: https://nodejs.org/en/download/
Documentation: https://nodejs.org/en/docs/

Step 4: Install WebPack to the Development Environment using NPM (Node Package Manager)

Before installing Node Packages you need to add a package file and WebPack config. file to the project root directory.


1. package.json (List of Node packages and dependencies)

2. webpack.config.js (Configuration file for the Babel Bundle)

1. package.json




Sample Code:











2. webpack.config.js










































Install Nods Packages

Commands:


npm;
npm install webpack;
npm install webpack-cli;
npm install glob;
npm install babel-loader --save-dev;
npm install babel-polyfill --save-dev;
npm install @babel/preset-react --save-dev;
npm install @babel/preset-env --save-dev;
npm install react@17.0.2
npm install react-dom@17.0.2
npm install react-router-dom@6.2.2
npm install reactjs-popup@2.0.5
npm install style-loader
npm install css-loader
npm install @amcharts/amcharts4
npm install jquery
npm install datatables.net-dt
npm install datatables.net-responsive-dt
npm install react-datepicker

· -P, --save-prod: Package will appear in your dependencies. This is the default unless -D or -O are present.· -D, --save-dev: Package will appear in your devDependencies.
· -O, --save-optional: Package will appear in your optional dependencies.
· --no-save: Prevents saving to dependencies.


Adding Post Build Event:

Open project properties >> Build Events >> Post-build event command line
Add the below command line and save the properties
call npm run build

References:
https://react-popup.elazizi.com/component-api



Monday 9 January 2023

How to update the date automatically based on a specific week in Sitemap.XML using c#

Image by tirachardz on Freepik


Automatically Update the Date in Sitemap.XML based on a specific week in the world of search engine optimization (SEO), maintaining an accurate and up-to-date Sitemap.XML file is crucial. This file provides search engines with a roadmap of your website, helping them efficiently crawl and index your content. One common task is to ensure that the last modified date in the Sitemap.XML is automatically updated based on a specific week. This can be easily achieved using C#.

If you have a small website where content changes happen either on a weekly- or monthly-
basis, you can simply create an XML- and HTML-sitemap by hand.

How do I create a sitemap for my website?

If you have a website with many pages and an almost daily update frequency, such as a blog, it is quite handy if you can automatically generate a new sitemap anytime new content is ready.

Many of the different Content Management Systems (CMS) that are available have their own add-ons (plugins) that can automatically create sitemaps for you. The one thing to keep in mind with these plugins is that each additional CMS plugin will lead to a (minimal) worsening of your website’s loading time (Page Speed). A pay-to-use alternative for an automatic sitemap creation, which is not bound to any CMS, is being offered, among others, by XML-Sitemaps.com as a SaaS- (Software as a Service) or self-hosted-solution:

SaaS: https://pro-sitemaps.com/ (free for up to 500 pages)

More alternatives automatically generating sitemaps:

(Deprecated) Google Code page for sitemaps


Below is the code to update data in a sitemap based on a specific week.




SiteMap Daily Updation:


YOU SHOULDN'T ONLY BELIEVE OUR WORDS

What My Clients Say - Testimonials | Review Great Job!!! Karthik Karthik is a very talented IT person. I have known him for 4-5 years. He i...