Monday, 25 January 2016

ASP.NET

What is Asp?

Ans: Active Server pages also known as classic Asp. Asp is a Microsoft server sided technology which helps to make dynamic and user-friendly web pages . It uses different scripting languages to create different dynamic web pages which can run any browser. The web pages are built by using VB script or JavaScript. Asp is implemented through a dynamic-link library (Asp.dll) that is called by the IIS server when a Web page is requested from the server.


What is Asp.Net?

Ans: Asp.Net is a specification developed by Microsoft to create dynamic web applications, web sites, and web services. It is a part of .NET Framework. You can create Asp.Net applications in most of the .Net compatible languages, such as Visual Basic, C#, and J#. The Asp.Net compiles the web pages and provides much better performance than scripting languages, such as VB Script.


What is difference between Asp and Asp.Net?

Ans: The basic difference between Asp and Asp.Net is that Asp is interpreted whereas Asp.Net is compiled. This implies that since Asp uses VB Script therefore, when an Asp page is executed, it is interpreted. On the other hand, Asp.Net uses .Net languages, such as C# and VB.Net, which are compiled to Microsoft Intermediate Language (MSIL).


What is IIS? Why it is used?

Ans: Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to Asp.Net Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server.


What is Platform?

Ans: PHP, JAVA, .NET are examples of platforms or development platforms. This becomes the core of web application. Developers work on different platforms.


What is Framework?

Ans: Framework is set of predefined functions and classes which developer uses for faster development. MVC is a type of framework. Popular examples in PHP would be CodeIgniter and Zend Framework. Framework gives you a set of tools to help you write the code faster and better.


Types of Models in Asp.Net?

Ans:
  •  Web Pages  (Single Pages Model)
  • MVC  (Model View Control)
  • Web forms  (Event Driven Model)
             

Different Approaches in Asp.Net?

Ans:
  • Model First
  • Database First
  • Code First

Model First:

In the model first approach First we create model in a way that all the entities interact directly to each other.

Here the presentation of model...



  • Open Visual Studio
  • Create New Project
  • Select web & click on web project
  • Right click on project and Add New Item 
  • Select Data From Left Side
  • Add ADO.Net Data Model 





  • Select Empty Model






  • Create Model According to your project






  • After Making Model Generate Database Form Model






  • Select the Database






  • Generate Database






  • Here Create Model EDMX File








Database First:

In the database first model we create the tables and then pick these existing tables to map with model.

Here the presentation of model...


  • Open Visual Studio
  • Create New Project
  • Select web & click on web project
  • Right click on project and Add New Item 
  • Select Data From Left Side
  • Select Generate From Database






  • Choose All the Database Tables which you create Already
  • Press Finish Button 





  • Model will be created







Code First:

In code first approach we firstly create classes and then generate the database from classes directly. In this approach we do not need of generate model e.g edmx files.


Here the presentation of  model...



  • First Of All Create Classes



public class Category
   {
      public int CategoryId { get; set; }
      public string Category { get; set; }
      public string Description { get; set; }
   }

   public class Product
   {
      public int ProductId { get; set; }
      public string ProductName { get; set; }
      public float Price { get; set; }
      public int CategoryId { get;set;}
   }


  • Define the DB Context Classes which Came From Drived DBContext



public class SampleContext : DbContext
   {
      public DbSet<Category> Categories { get; set; }
      public DbSet<Product> Products { get; set; }
   }

  • For Performing The CRUD Operations Define the Data Access Class With Proper Functions.



public class SampleDataAccess
   {
      SampleContext  context = new SampleContext();
      public List<Product> GetProducts()
      {
         return (from p in context.Products select p).ToList();
      }
   


  • Add Connection String To The Web.Config File For Access Database


<add name="SampleContext"
   connectionString="datasource=.\sqlexpress;IntegratedSecurity=SSPI;database=SampleDB"
   providerName="System.Data.SqlClient"/>


  • Now Select Object From The Choose Data Source Type Menu And Specify An Id For The Data Source.






  • Select Data Access Class From The List.







  • Select CRUD Operations From Get Product Method. 







  • Tables Will Be Generated.














No comments:

Post a Comment