Posts

Adding ASP.NET MVC5 Identity Authentication to an existing project

https://stackoverflow.com/questions/31960433/adding-asp-net-mvc5-identity-authentication-to-an-existing-project https://code.msdn.microsoft.com/ASPNET-MVC-5-Security-And-44cbdb97 https://www.c-sharpcorner.com/article/create-identity-in-simple-ways-using-asp-net-mvc-5/ https://stackoverflow.com/questions/31960433/adding-asp-net-mvc5-identity-authentication-to-an-existing-project

SECURING WEBAPI USING JSON WEB TOKEN (JWT) IN WEB API C#

Image
ref site :  http://www.decatechlabs.com/secure-webapi-using-jwt Step 1 : Step 2 : Step 3 : Step 4 : Now replace all code with below code using   Microsoft . IdentityModel . Tokens ; using   System ; using   System . Collections . Generic ; using   System . IdentityModel . Tokens ; using   System . IdentityModel . Tokens . Jwt ; using   System . IO ; using   System . Linq ; using   System . Net ; using   System . Net . Http ; using   System . Security . Cryptography . X509Certificates ; using   System . Threading ; using   System . Threading . Tasks ; using   System . Web ; namespace   WEBAPI_JWT_Authentication {      internal   class   TokenValidationHandler   :   DelegatingHandler      {          private   static   bool   TryRetrieveToken ...

Download file by anchor click with different Name

<a href="http://localhost:53258/Content/Javascript%20Testing.html" target="_blank" download="a.pdf">Download Now</a>

Convert File to Byte Array and Byte Array to Files

1.  Create an ASP.Net application and add a class Document. public class Document    {         public int DocId { get; set; }         public string DocName { get; set; }         public byte[] DocContent { get; set; }     } 2.  Create a file of format doc/pdf/rtf etc. and convert the file content to a ByteArray using the following method. Then create an object of type Document and assign the Docname and DocContent property values from filename and filecontent. public Document FileToByteArray(string fileName)        {             byte[] fileContent = null;             System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);  ...

Phone Masking by sql server

declare @str varchar(50) ='43-2423-4234' select 'XXX-XX-' + RIGHT(@str,4) as MaskedTaxNumber

Upload HTML To Convert into PDF in MVC

Download project from below link https://drive.google.com/file/d/1efu6TZvnbUBrgg2gtA-mW-rPq_zg3xRs/view?usp=sharing

Dynamic query paging using MSSQL Server Without Offset

CREATE PROCEDURE [dbo].[SPPaging]   @CurrentIndex AS INT,   @PageSize AS INT,   @SortColumn AS VARCHAR(MAX),   @SortOrder AS VARCHAR(10),   @TotalRecord AS INT OUTPUT,   @WhereClause AS VARCHAR(MAX)  AS  BEGIN  BEGIN TRY     DECLARE @LowerBound AS INT,     @UpperBound AS INT,     @Sql AS NVARCHAR(MAX),     @ParmDefinition AS NVARCHAR(MAX);     SET @LowerBound = @CurrentIndex;     SET @UpperBound = (@CurrentIndex - 1) + @PageSize;   BEGIN TRANSACTION          EXEC('SELECT A.* FROM(SELECT ROW_NUMBER() OVER(ORDER BY ' + @SortColumn+ ' ' +  @SortOrder+ ')SrNo,D.Id,      D.FirstName,      D.LastName,     D.CreatedDate     FROM [dbo].[Driver] D     LEFT JOIN [dbo].[Intermediate] I on I.[IntermediateID]=D.[In...