Category: ASP.Net MVC

  • How to enable “Windows Authentication” for your websites?

    There are few things which we need to do before access the website using windows authentication. Web.config: Add or replace existing Authentication Tag IIS Express with Visual Studio: Click on your project in the Solution Explorer to select the project. Open Properties pane suing F4. In the Properties pane for your project: a) Set “Anonymous…

  • ASP.NET MVC Redirect to Action from a Class

  • Cannot load MVC4 Web project in VS 2017 or VS 2019

    I have a web project, it could load fine in VS15, but in VS2019 it’s failing, saying the project is incompatible. The migration report contains the following message: ========== .csproj: The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?LinkID=299083&projecttype=E3E379DF-F4C6-4180-9B81-6769533ABE47 To resolve it: 1. Open…

  • Missing Windows Authentication Feature IIS and Windows 10

    If you have windows 10 Home or SL version when might be you are unable to see Windows Authentication under IIS options when installing. To enable “Windows Authentication” either you need to upgrade the OS to Pro version or you can run this command to enable it. C:\WINDOWS\system32>dism /online /norestart /add-package:%SystemRoot%\servicing\Packages\Microsoft-Windows-IIS-WebServer-AddOn-2-Package~31bf3856ad364e35~amd64~~10.0.17134.1.mum The file name will…

  • How to Backup Microsoft SQL Server (MSSQL) Databases

    –1. Variable declaration DECLARE @path VARCHAR(500) DECLARE @name VARCHAR(500) DECLARE @filename VARCHAR(256) — 2. Setting the backup path SET @path = ‘X:\MSSQLDB\Backup\’ DECLARE db_cursor CURSOR FOR SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN (‘master’,’model’,’msdb’,’tempdb’) — ignore system databases –3. Initializing cursor operations OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name WHILE @@FETCH_STATUS = 0…

  • How to Create Multiple SQL Server Instances on Same Server

    When you install SQL Server, the installation creates an instance (DEFAULT OR SQLEXPRESS) of SQL Server. In my case I have created instanace named DEVSQL. Some times we do need to create multiple instances based on requirements. To create more instances, start the setup again. The following screen appears when setup starts for the SQL…

  • How to speed up database and table listing in Management Studio

    In SQL Management Studio, select the “Databases” node in the Object Explorer. Then, click View –> Object Explorer Details. Right click on one of the column headers and uncheck all of the columns besides “Name”. These columns are slowing down the process of expanding the database list.

  • How to get list of all always encrypted columns in SQL Server

    We do have “Always encrypted” feature in SQL 2016 and later versions, from this feature we can encrypt the column data instead of encrypting whole database.  Sensitive data like credit card numbers, SSN. We need to prepare a list of encrypted columns at some where to track for future. Without tracking anywhere in the documents…

  • SQL Server – List all the Constraints by Table or by Column Name

    List all Constraints of the Database: [sql]SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS OR SELECT OBJECT_NAME(object_id) AS ConstraintName, SCHEMA_NAME(schema_id) AS SchemaName, type_desc AS ConstraintType FROM sys.objects WHERE type_desc LIKE ‘%CONSTRAINT'[/sql] List Constraints  on table column: [sql] Select SysObjects.[Name] As [Contraint Name] ,Tab.[Name] as [Table Name],Col.[Name] As [Column Name] From SysObjects Inner Join (Select [Name],[ID] From SysObjects Where XType…

  • The provided anti-forgery token was meant for user “”, but the current user is “user@example.com”

    While working with Asp.net MVC, I got HttpAntiForgeryException exception (The provided anti-forgery token was meant for user “”, but the current user is “user@example.com”) at login page. It happens when user login with valid credentials and re-directed to inner page ofr the application. At inner pages he press the browser back button and will show…