ASP.Net Core SPA Application Command Line

ASP.NET Core is initialized from the Startup class in the application

wwwroot folder contains static files (like js, css and image files for our web application).

project.json file. JavaScript object notation to store configuration information and it is this file that is really the heart of a .NET application.

<environment names=”Development”>
<link rel=”stylesheet” href=”~/view-resources/Areas/AppAreaName/Views/Users/Index.css” asp-append-version=”true” />

<environment names=”Staging,Production”>
<link rel=”stylesheet” href=”~/view-resources/Areas/AppAreaName/Views/Users/Index.min.css” asp-append-version=”true” />

Below are the commands to setup SPA in ASP.Net Core


dotnet new –install Microsoft.AspNetCore.SpaTemplates::*

dotnet new angular

dotnet restore

npm install


  • npm i -g webpack
  • npm i webpack-compiler

How to change environment in ASP.Net Core application?

If are getting error after deploying your ASP.Net Core application in Azure PaaS environment and want to see quick error stack then you need to make change in web.config file

1. Web.config file settings:-

<aspNetCore …>
<environmentVariable name=”ASPNETCORE_ENVIRONMENT” value=”Development” />

Also check your appsetting.json file.

SharePoint Check User Permission

This is code snippet to check if user has role permission

/// Find the particular role definition to check agaionst the user has permisson
SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
SPUser siteUser = web.SiteUsers[“SP\\mukesh”];

///Get all permission for the selected user
SPPermissionInfo userPermissions = web.GetUserEffectivePermissionInfo(siteUser.LoginName);

///Check role is is assigned to the user
var memberof = userPermissions.RoleAssignments.Where(role => role.RoleDefinitionBindings.Contains(roleDefinition)).Select(roleMember => roleMember.Member).ToList();



How To avoid assembly registration in Web.Config for the Object Data Source

It’s very common to use object data source to bind the grid , formview etc but the problem is Assembly registration in web.config specially in multi server farm.
In order to avoid the registration of your assembly in web.config file just follow two simple steps as mentioned below.


In your UserControl ASCX file add assembly directive

<%@ Assembly Name=”ILX.MKS.Business, Version=, Culture=neutral, PublicKeyToken=123a45b9c456789″ %>


    In object data source give fully qualified type Name like below

    TypeName=”ILX.MKS.Business.UserRegistration, ILX.MKS.Business, Version=, Culture=neutral, PublicKeyToken=123a45b9c456789″

Note: –
There are pros and cons of the above option, this is helpful if you do not want to touch the web.config file, otherside is if you maintain in web.config then  will be central location to maintain
the assembly reference.




JQuery Add new item in table

Code sample


Click here to View Demo 


<!DOCTYPE html>
<script src=””></script&gt;
table, td {
border: 0px solid black;

<p>Click the button to add a new row at the first position of the table and then add cells and content.</p>
<table style=’display:none;border: 1px solid red;’ id=”myTable”>
<td><input type=’text’/></td>
<option value=”volvo”>Volvo</option>
<option value=”saab”>Saab</option>
<option selected value=”mercedes”>Mercedes</option>
<option value=”audi”>Audi</option>
<td><input type=”button” value=”Delete Row”></td>

<div class=”dynamiTbl”>
<table id=”myTableMain”>
<td><input type=’text’/></td>
<option value=”volvo”>Volvo</option>
<option value=”saab”>Saab</option>
<option selected value=”mercedes”>Mercedes</option>
<option value=”audi”>Audi</option>
<td><input type=”button” value=”Delete Row”></td>


<button id=’btnAddMore’ onclick=”myFunction()”>Add more</button>

var totalItem=0;
function myFunction() {
var table = document.getElementById(“myTable”);

var tableMain = document.getElementById(“myTableMain”);

var clone = table.getElementsByTagName(‘tr’)[0].cloneNode(true); // copy children too
if(tableMain.getElementsByTagName(‘tr’).length <= 10)
var tds =clone.cells[0];//
var inptText = tds.getElementsByTagName(‘input’);
tds =clone.cells[1];//
var inptSelect = tds.getElementsByTagName(‘select’);
inptSelect[0].selectedIndex =-1;



$(“.dynamiTbl”).on(“click”, “#myTableMain tr input[type=’button’]”, function(e) {




How to create List with Item Order enabled

In order to enable feature in a list to change item order, it will be better
to create your list definition go to schema.xml and specify OrderedList=”TRUE”

and in the same schema.xml file go to view and change Order by CAML like..

<View BaseViewID=”1″ OrderedView=”TRUE”

<FieldRef Name=”Order”></FieldRef>


Now add some data into the list created based on above list definition
and then go to http://yoursitename/_layouts/Reorder.aspx?List=listGuid

This is manual process but can be added into ribbon button by adding
custom action for the list definition.