Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts

Tuesday 21 April 2020

Optimization in MVC


  1. Optimization is the technique that is used to reduce the size of CSS and Script in bundleConfig.cs
  2. It make bundle compact and smaller in size.
  3. optimization work in release mode by default it is disable in debug mode.


Syntax Of optimization:-  this syntax is used in the global.asax. we can enable or disable the optimization with the help to set as true or false.

  public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            System.Web.Optimization.BundleTable.EnableOptimizations = false;
        }
    }

Thursday 9 May 2019

Difference Between ASP.NET MVC And ASP.NET Core

We love to develop websites and web applications. When we create an enterprise application, we often choose ASP.NET MVC over ASP.NET Core. Here are the basic differences: 
 
ASP.NET MVC
 
ASP.NET framework is a highly testable and powerful framework. It's a web form based framework. You can create applications in ASP.NET (.aspx) or Razor page. MVC has three major parts - Model, View and Controller.
  • Model Model represents the data business logic layer. It maintains the data in the whole application. Model object retrieves and stores data in the application.
  • View View is a user interface (what we see on a website and application). View displays the data using Model and user input, and also modifies that data.
  • Controller 
    Controller handles all the user requests and processes using Model and display View part. It provides control over the user requests, URL path change (Routing), and many other operational controls.
ASP.NET MVC gives you a pattern-based way to develop dynamic websites and applications. It has many features and powerful tools. You can learn MVC and easily working with Routing, UI, Layout, Theme, data, API, and others.
 
ASP.NET MVC isn't open source. It's controlled and developed by Microsoft.  
 
ASP.NET Core 
 
ASP.NET Core is a "learn and compose" based framework to develop an application. It mainly focuses on fully open source and ASP.NET Core available on Github. You can develop  ASP.NET Core easily.
 
ASP.NET Core also focuses on another region. It's cross platform, which means you can use it on Windows, Mac or Linux. The previous version ASP.NET MVC was not cross-platform and worked only on Windows.

Wednesday 1 May 2019

How to set Html.RadioButtonFor as selected by default in Asp.net MVC3

The below is the code snippet of how to use the Html helper for Radio Button in Asp.net MVC.
<td> Will Accept?</td>
 <td>
@Html.RadioButtonFor(x => x.WillAccept, true)
@Html.RadioButtonFor(x => x.WillAccept, false)
</td>

The first option is to pass the “checked” html attribute as a parameter to the Html helper method by creating an anonymous object as below
<td> Will Accept?</td>
<td>
@Html.RadioButtonFor(x => x.WillAccept, truenew { @checked = “checked” })
@Html.RadioButtonFor(x => x.WillAccept, false)
</td>
The Second option is to set the value of the corresponding model property in the controller itself
public ActionResult Feedback()
{
UserResponse usr= new UserResponse();
usr.WillAccept = false;
return View(“Feedback”,usr);
}
Both work perfectly, but note that, setting the value via model overrides passing via html parameter. So if both of the above options are used the default value of the radio button will be false.
Leave a reply if you find it useful

Wednesday 17 April 2019

MVC Folder Directory Struncture

Directory Structure:-

Some people for the fast-developing code doesn’t think about directory structure. but for the long project it will affect the project maintainability. There are lots of way to structure the application.

in this article we will learn how to create folder directory structure and what the meaning of folder.

In the directory structure, we will follow the following step: -

  1.  Open Visual Studio -> click new Project-> Asp.net web application
  2.  Give the Application Name that you want
  3. Right Click Application-> Add Folder ‘App’
then you see the application contain the folder as show in below image











































1.App_Data:- App_Data contains the data like .mdf ,Xml file and other data related files.
2. App_Start:- it contains the  class files like BundleConfig.cs, FilterConfig.cs, RouteConfig.cs etc.
     BundleConfig.cs contains the bundle of js and css , RouteConfig.cs contains the default path of the application.




2. Content:- content folder contains the file Likes CSS , icon, images etc. means related to the designing part.



3. Controller:- it the heart of the MVC application. Controller contains the class files. it is responsible for controlling the flow of application execution.



4. Model:- contains the class files that is used in the view.



5. Scripts:- it contains all the .Js Files



6. Views:- it contains the HTML files . it is the design part of the application















What is Agile,advantage and disadvantages

Introduction:- It is a software development life cycle used for software development, that is characterized by the division of tasks in...