Skip to main content

Posts

Showing posts from March, 2019

Connection String in ASP.NET With SQL Server

Connection string can be placed in web.config file found in root directory of the application from .NET 3.5 onward. connection string can be specified with an xml tag  <connectionStrings>  inside  <configuration>  section of web.config file. < connectionStrings > < add name = "myConnectionString" connectionString = "Data Source=databaseServerName; database=database-name; uid=sqlUserName;password=sqlPassword; Integrated Security =True|false|SSPI (any one options) ; " providerName = " System.Data.SqlClient System.Data.SqlClient" /> </ connectionStrings > We can use local database server of SQL Server by using Data Source= (LocalDb)\MSSQLLocalDB we can attach a local database file to the app_data directory by using the property AttachDBFilename=|DataDirectory|\appDatabaseName.mdf in the connection string Connection String can be

Knowing Nuget and installing a Package

 For .NET Microsoft-supported mechanism for sharing code is  NuGet , which defines how packages for .NET are created, hosted, and consumed, and provides the tools for each of those roles. It has been an essential tool for through which developers can create, share, and consume useful code. Often such code is bundled into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages. How to add Nuget Package to an application Right click Refrences -> Manage Nuget Packages 2.  Type Nuget Package Name you need for the application here we add Entity Framework 3.   After the search result is shown click install and accept the agreement asked After this the package is installed and you can use the functionalities that are provided by the package.

Models In Asp.net MVC

What is a Model? Model is a class that represents domain specific data and business logic in a dot net application. Adding A Model  Right click the Models folder in the solution explorer->Add -> Class After that Select Visual C#-> Class  and provide a suitable name for your model class Sample Model Class In Model validation logic can be added using Attributes in C# . Some validation attributes like StringLength,RegularExpression are used in the model.

Getting Started With ASP.NET MVC First Application

Requirements: Visual Studio (i am using VS 2017 for demo) Open up the visual studio and Click File -> New ->Project   Click Visual C# -> Asp.Net Web Application (.NET Framework)                                              In the Name i.e Project Name and Solution give the name as required here I have given      Name: WebApp                                                                                                                              Solution Name: StudentInformation Select MVC and then click OK The application will open with the following view Run the application from the menu bar or can press F5 or CTRL+F5  The first ASP.NET MVC Application is up and running in your web browser. It opens the applications home page and opens in the web browser with localhost:port . Visual studio assigns the random port number and hence the port number you see differs.

Introduction to ASP.NET MVC

What Is Asp.Net MVC ?  Asp.net MVC is a framework introduced by microsoft in 2008 for building web application. Asp.net MVC is an architectural pattern built on top of ASP.Net Framework for development of application based on three main logical components. Asp.net MVC is lightweight and testable framework and can be used to develop highly scalable and extensible enterprise level applications. Three main components of MVC 1. Model   Model is a data specific logic that the application works with.It generally represents the data that is transferred between storage layer and application and between view and controller. In general Model is a class that contains properties specific to the application domain and transfer data between different components. 2.View View is an user interface that can use model to populate data to the users. They are results of the request made by an user to the application and is returned from controller. 3. Controller Controller is a component that