Showing posts with label c# Tutorial. Show all posts
Showing posts with label c# Tutorial. Show all posts

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

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

Saturday 28 November 2020

ASP.Net 404 page not found error handle

 



When a URL hits and if page is not found on the server then ASP.Net throws a 404 page not found exception. If 404 page not found exception handled properly then you will get the default error page by ASP.Net , Which doesn't looks good and user friendly. 404-page handling is considered as a good practice of web development. Paste the following code on Global asax file and you will be redirected to your custom error page. 

Tuesday 10 November 2020

Google Captcha for C# ASP.Net MVC

 

reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to keep malicious software from engaging in abusive activities on your website. Meanwhile, legitimate users will be able to login, make purchases, view pages, or create accounts and fake users will be blocked.

Monday 5 October 2020

Form post ASP.Net | C# | MVC

 


HTTP is a protocol that is used to provide a communication interface between server and client. HTTP sends data to the server and retrieved response to the client(Browser). HTTP has many methods for client/server communication.

HTTP GET and HTTP Post is the most common method used by HTTP. 

  • HTTP Get the return response from the server to  client.
  • HTTP Post send data client (Browser to the server) .
I am going to explain to you that how can you save data of a form using form post methods. I was a PHP developer when used the MVC C# form then I had to use ajax for data submission to the server which was very time taking and prone to error.


ASP.Net MVC C# has a built-in model attached view for form data submission and validation, which is good but not good as for users who are using simple posts form the method. So I will show you different ways to send data to the server using form method post like PHP.

Demo Table Name (Student)


SN

Field

Data Type

1

Roll

Int

2

Name

Varchar(50)

3

City

Varchar(50)

Store Procedure

Wednesday 9 September 2020

Get Date dd/mm/yy format using format string C# | ASP.Net

ASP.Net has reach variety of date processing techniques . If yoo want to date as in dd-mm-yy format then you can use format string which help you to set your date output as you want. Using format string increase your ourput by just a line of code.

DateTime dt = DateTime.Now;

string format = "ddmmyy";

string postfix = dt.ToString(format);    

Output : 110920        

Console.WriteLine(postfix);

You can use different versions of format string as per your requirement . 

string format = "dd-mm-yy";
Output : 09-11-20

string format = "DDD mm yy";
Output : Wed 09 20

Format string pattern

M display one-digit month number d display one-digit day of the month h display one-digit hour on 12-hour scale mm display two-digit minutes yy display two-digit year

Saturday 5 September 2020

Bind dynamic layout on a single view using C# | ASP.Net

 

ASP.Net MVC is a popular platform to design dynamic website and CRM etc. One I was stuck in a situation when I want to use a common view to different privileged users. So I had to bind multiple layouts on a single view as per the related users menu or sidebar. This post will help you to bind dynamic layouts on a single view.

  public ActionResult Task()

        {

File Resizing C# | ASP.NET | MVC

 

You can resize your image as per your requirement by using WebImage Class which implemented in System.Web.Helpers namespace and resizing is done by Resize and save method.

Namespace : using System.Web.Helpers;

[HttpPost]

        public JsonResult UploadCommonImage(string fnm, string pth,string w,string h)

        {