Showing posts with label asp.net. Show all posts
Showing posts with label asp.net. Show all posts

Monday 21 August 2023

CaptchaMvc Mvc5 | C# ASP.Net

 CaptchaMvc Mvc5 Using C# ASP.Net Visual Studio 2019



CAPTCHA stands for "Completely Automated Public Turing test to tell Computers and Humans Apart". It is a test used to distinguish between humans and computers. CAPTCHAs are often used to prevent automated spam and abuse.

Friday 10 March 2023

CCAvenue Integration with C# ASP.NET MVC

 

CCAvenue Integration

CCAvenue integration with complete step-by-step code for C# ASP.NET MVC Pattern.


CCAvenue is one of the most powerful and popular payment gateways which support all types of payment methods. Integration of CCavenue with ASP.NET is quick and easy but the main problem is, Integration kit provided by the CCAvenue is implemented in the ASP.NET form application. Which is not in trend right now. ASP.NET MVC with C# is trending now. So this post will help you to implement CCAvenue with ASP.NET C# MVC pattern using visual studio 2019.


Process Login

  • Signup with CCavenue and get the CcAvenueMerchantId,CcAvenueWorkingKey, and CcAvenueAccessCode. To get this code please refer to the ccavenue documentation or use youtube because this information is available easily. So I am going to leave this to make this post smaller.
  • Download the Integration kit named ASP.Net_Kit_Version_2.0.
  • Drop an email to service@ccavenue.com with your website URL because CCAvenue entertains only register URLs sent by users by mail.
  • CCavenue provides a form with mandatory and optional parameter then encrypt user input and send it to the server.

Step 1 

  • Create an account on CCAvenue and get CcAvenueMerchantId,CcAvenueWorkingKey, and CcAvenueAccessCode.


  • Drop an email to service@ccavenue.com with your website URL because CCAvenue entertains only register URLs sent by users by mail.

Thursday 15 December 2022

FormsAuthentication C# ASP.NET MVC

 


FormsAuthentication

FormsAuthentication class from System.Web.Security is used to authenticate a user whether login or not. FormsAuthentication class has many functions to check the user login and it's very easy to implement. Follow the code given below

Views

<h2>Login</h2>

<form method="post">

    <input type="text" name="UserName" placeholder="User Name"  required /><br /><br />

    <input type="password" name="Password" placeholder="Password" required /><br /><br />

    <input type="submit" value="Login" />

    @if (Request.QueryString["msg"] != null)

    {

        <br /><br />

        <span style="color:red">@Request.QueryString["msg"]</span>

    }

</form>

Thursday 10 November 2022

Make PDF from hyperlink | ASP.NET C#


 This post will help you to create a PDF file from a URL in ASP.Net C#. Follow the steps given below. We will save a PDF file on the server then after viewing the PDF file, the file will be deleted. 

Step 1 : 

Download Select.HtmlToPdf.NetCore package from NuGet. 

Goto Tools Menu>Nuget Package Manager > Manage Nuget Package for Solution

Step 2 : 

 
 Create a Button and call the javascript function, which will create a PDF file from the given URL. The passing argument is URL of the page. Which will be converted into PDF file on the server at the given path. Then you can download the file.

<input type="button" value="Get PDF" onclick="createPDF('https://girfa.co.in/')" />

Step 3 


Javascript Code

function createPDF(pageurl)
 {

         $.ajax({

                url: '/Common/htmltopdf/',
                async: true,
                dataType: "json",
                type: "GET",
                contentType: 'application/json; charset=utf-8',       

                data: { url: pageurl},

                success: function (data) {              

                    DelPDF('/upload/print/' + $.trim(invid) + '.pdf');                   

                    window.location.href = '/upload/print/' + $.trim(invid) + '.pdf';                          

                }

            });          

        }

 

function DelPDF(path) 
{          

            $.ajax({

                url: '/Common/DeleteCommonFile?path=' + path,

                type: "POST",

                contentType: false, // Not to set any content header

                processData: false, // Not to process data           

                 success: function (result) {

                    //Update Extension
                    if (result.sMessage == "1")
                    {
   

                    }
                    else
                        alert(result.sMessage);

                },
                error: function (abc) {
                    alert(abc.statusText); 

                }

            });

}

Step 4

Controller C# code

public JsonResult htmltopdf(string url,string inv)

        {

            // instantiate a html to pdf converter object

            HtmlToPdf converter = new HtmlToPdf(); 

            // create a new pdf document converting an url
            PdfDocument doc = converter.ConvertUrl(url); 

            // save pdf document

            doc.Save(Server.MapPath("~/upload/print/" + inv + ".pdf")); 

            // close pdf document

            doc.Close();

            return Json(new { sMessage = "11"}, JsonRequestBehavior.AllowGet); 

        }

 

[HttpPost]

        public JsonResult DeleteCommonFile(string path)
        {

            try
            {

                string filename = Server.MapPath(path);
                if (System.IO.File.Exists(filename))
                {

                    System.IO.File.Delete(filename);

                } 

                return Json(new { sMessage = "1", JsonRequestBehavior.AllowGet });

            }

            catch (Exception ex)
            {

                return Json(new { sMessage = ex.Message, JsonRequestBehavior.AllowGet });

            }

        }


Thursday 13 January 2022

Multiple file upload by form post ASP.NET C# MVC


Multiple file upload by form post ASP.NET C# MVC


This post will let you upload multiple image files through a single form post using the C# ASP.Net MVC platform.

Key Point

  • Upload multiple image files with a new name
  • Save a associate record and file name will be newly created record identity field value
  • No need to save the image name in the database because the file name will start with a record ID and end with a text. 
  • Best for putting student, employee documents without any hassle. 

HTML Code : 

<form method="post" enctype="multipart/form-data">

     @Html.AntiForgeryToken()

    <p class="m-0">

        Photo

        <input type="file" name="Photo" id="Photo" accept="image/x-png,image/jpeg" />

        <br />

        Adhaar

        <input type="file" name="Adhaar" id="Adhaar" accept="image/x-png,image/jpeg" />

        <br />

        Pan

        <input type="file" name="Pan" id="Pan" accept="image/x-png,image/jpeg" />

        <br />

        <input type="checkbox" id="chkconfirm" /> I provide my consent. I will follow the Tangentweb term condition and policy.

        <br /> <br />

        <input type="submit" value="Save" class="button button-primary button-wide-mobile" onclick="return filecheck()" />

    </p> 

</form>

Thursday 4 November 2021

Fill Menu items in partial view from database without using java script in C# ASP.NET MVC

 Fill Menu items in partial view from the database without using javascript in C# ASP.NET MVC.

Menu items from database


When there is a need to load menu items from the database, then you may have many options like load it from javascript. But the best load time is when you use Razor collaborate with C#. This post will help you to do the same. Follow the step-by-step instructions. I Guarantee that response time is the lowest than any other approach. 

Model

public class MenuModel

{

   public string ID { get; set; }

   public string MenuName { get; set; }

}

Friday 22 October 2021

Read INI file ASP.Net MVC C#

 Install ini reference 

> nuget install ini-parser
                or
PM> Install-Package ini-parser

Friday 15 October 2021

Save file to server without java script C# ASP.Net

 In this post, you will learn, How to upload an image file to a server without using javascript or jquery. The file will be upload using C#. Unique File name  is generated with datetime string , you implement your logic for the file name. Given code is applicable in both C# MVC and ASP.Net both.

Name Space

using System.IO;


HTML

Saturday 12 June 2021

Stripe Integration with C# ASP .NET MVC Visual Studio 2013

 Stripe payment gateway integration in ASP.NET C# MVC using Visual Studio 2013



Stripe payment gateway is simple but documentation for integration is very complicated. Current integration documentation is written for .Net core and if your project is made with visual studio 2013, then it would be very complicated to integrate because no documentation is available for the version of VS 2013. So I have made this post which will help you to strip integration with ASP.Net MVC using C#.

Monday 7 June 2021

Install NuGet Package in Visual Studio 2013 | Microsoft ASP .NET

 Install NuGet Package in Microsoft Visual Studio 2013 ASP.NET



Current NuGet package does not support default TLS version (1.1). This is by default in Microsoft Visual Studio 2013. So You cannot install packages from Nuget package console. If you want to install nugget package in visual studio 2013 , then you will have to update TLS version (1.1) by the command given below.

[Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol-bOR [Net.SecurityProtocolType]::Tls12

Monday 17 May 2021

Solved : Application of .NET Technology January 2020

 Solved :  Application of .NET Technology January 2020

1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “OMR” answer sheet supplied with the question paper, following instructions therein.
(1x10=10)

1.1 : Which utility can be used to compile managed assemblies (like Dll’s and EXE) into native code ?
(A)    ngen (B)     gacutil
(C)    dumpbin (D)    ildasm

Tuesday 20 April 2021

Custom Error message | Hide Yellow Screen Of Death (YSOD) page in ASP .Net

ASP.Net MVC has a default error view in the Shared folder. which shows when any unexpected error arises. By default a fixed static error message display, No details of error shows. So if you want to show error details then this post will help you.




Yellow Screen Of Death (YSOD)

When an unhandled exception arises in an ASP.NET application one of three types of error pages is displayed: By default, ASP.NET displays an error page that is affectionately referred to as the Yellow Screen of Death (YSOD). YSOD showed some Sensitive information that can be used by attackers . Show its good practice to show custom error info in front of your users.

Setting in Webconfg file

<system.web>

    <compilation debug="true" targetFramework="4.7.2" />

    <httpRuntime targetFramework="4.7.2" />

       <trust level="Full" />

      

       <customErrors mode="RemoteOnly"

                      defaultRedirect="~/Shared/Error.cshtml" />

  </system.web>


Show error in custom error file



 @model System.Web.Mvc.HandleErrorInfo 

<div class="container">       

        <h1>Error.</h1>

        <h2>An error occurred while processing your request.</h2>

        <h3 style="color:red"><p style="color:red"> @Model.Exception.Message</p></h3>

        <br /><br />

    </div>

Next Topic