Showing posts from January, 2022

Applying Policy-based Authorization in ASP.NET Core

Photo Credit: unsplash/maurosbicego In this post, we will learn how to implement authorization by applying policy-based authorization in ASP.NET Core. In previous versions of ASP.NET MVC such as version 5.2 it was possible to implement a custom authorize attribute and override AuthorizeCore(HttpContextBase httpContext). But in ASP.NET Core this is no longer possible, the recommended approach by Microsoft ASP.NET Core team is to use the declarative role and a rich policy-based model. Enabling Policy-b…

How to Upload a File in ASP.NET MVC 3.0 Using HTML Input File Control

In order to develop a functionality to upload file in ASP.NET MVC 3.0 you must use the Html input file here is the sample code: @ using (Html.BeginForm( "Index" , "Home" , FormMethod.Post, new { enctype = "multipart/form-data" })) { <input type= "file" name= "file" /> <input type= "submit" value = "Submit" /> } As you can see, this code should be added in the .cshtml file. You can definitely add more input fields to build your subm…

How to Implement Global Exception Handling in ASP.NET Core Application

In this tutorial, we will learn how to implement global exception handling in an ASP.NET Core application. Exception handling is one of the important features of any application, it is considered as a powerful mechanism to handle the runtime errors that may occur during the execution time of the application and without it we can't maintain the normal behavior of the web application. Therefore, we should always make sure to implement exception handling in a proper way. In ASP.NET Core, we should implemen…

How to Remove the Hosting Folder Name from MVC URL

I'm hosting several MVC websites on GoDaddy shared hosting. I noticed that the hosting folder name is being added by default to the URL.  This is not an issue in GoDaddy shared hosting but it is a normal behavior when hosting the website in a virtual directory. There are different ways to remove the hosting folder name from ASP.NET MVC URL. Here are some possible ways: Use Virtual Directory: A virtual directory is a folder that is not located in the website's physical directory structure but appears as if it is. You …

How to Upload an Image File in ASP.NET MVC 4

Uploading an image file in ASP.NET MVC 4 can be done using several different approaches, but one of the simplest and most effective is to use the HTML file input control and the HTTP POST method to submit the form. In this article, we'll go through the steps to implement a file upload in ASP.NET MVC 4. Step 1: Create a New MVC Project First, create a new ASP.NET MVC 4 project in Visual Studio. From the File menu, select New Project, and then choose ASP.NET MVC 4 Web Application. Step 2: Add the File Input Control Next, we'll add the fi…

How to get day/month/year from a date object in JavaScript?

Photo Credit: unsplash/steve_j How to format a date in JavaScript or How to get date in format 25/05/2022 in JavaScript? These are typical questions that we may need to answer when manipulating date objects using JavaScript. There is no direct function to format a date, here is what we can do to format a date object into "dd/MM/yyyy": var currentDate = new Date (); var month = currentDate.getUTCMonth() + 1 ; //getUTCMonth() returns 0-11 var day = currentDate.getUTCDate(); var year = currentDate.…

How to Remove the Top Banner from SharePoint Online Modern Pages

Photo Credit: unsplash/halacious How to Remove the Top Header in SharePoint Online Modern Page? When creating a page in modern SharePoint Online you will notice that the page includes a large header on the top of the page where you can upload and display an image as a banner along with the page title. In some situations, you may need to hide the top banner from SharePoint Online pages here are the steps: Click on the Settings gear and choose “Edit Page” to open the page in …

How to Login to Your SharePoint Online

Photo Credit: unsplash/@neonbrand To access the modern collaboration portal (or modern SharePoint Online ) you must be an authenticated user in Microsoft 365 and granted a valid license. In this post, we will go through the steps to login to SharePoint Online using any modern browser, you can also install the SharePoint mobile app on your smart device and access the portal however, this post will cover the web browser version.   Types of SharePoint Plans You can log in to SharePoint Online in multip…

SharePoint PnP PowerShell Error : The term ‘Connect-PnPOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

PnP PowerShell is a .NET Core 3.1 / .NET Framework 4.6.1 based PowerShell Module providing over 600 cmdlets that work with Microsoft 365 environments and more specifically SharePoint Online and Microsoft Teams. In order to execute any of these commands we must connect to SharePoint site by using 'Connect-PnPOnline' which creates a context that is required for the other PnP Cmdlets. Here is a reference of what you can do with this PowerShell module ( PnP PowerShell ). An error may occur if you are tr…

Tutorial: How to Read and Decode Messages from Azure Queue

What is Azure Queue Storage? Azure Queue Storage is a service for storing large numbers of messages. You access messages from anywhere in the world via authenticated calls using HTTP or HTTPS. A queue message can be up to 64 KB in size. A queue may contain millions of messages, up to the total capacity limit of a storage account. Queues are commonly used to create a backlog of work to process asynchronously. Queue Storage Concepts Azure Queue Storage implements cloud-based queues to enable com…

Fixing Yeoman ps1 Error ('npm\yo.ps1 cannot be loaded because running scripts is disabled on this system') when Creating an SPFx SharePoint Project

Introduction When you are creating a SharePoint SPFx project for the first time by running the following command " yo @microsoft/sharepoint ", you may receive an error that will block the creation of the project:  "File C:\Users\user\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170"   Solution This error occurs when running PowerSh…

Load More
That is All