SlideShare ist ein Scribd-Unternehmen logo
1 von 61
C# ASP.NET-MVC4 
Frameworks 
101 
Sept 06, 2014 
By Rich Helton
ASP.NET MVC 
Is Microsoft's framework in support of the 
Model-View-Controller, the most popular 
design pattern in the world for rapid development. 
Entity Frameworks are used heavily with 
ASP.NET MVC, but they are a completely separate 
framework that are used independently as well.
MVC Components
ASP.NET MVC benefits 
Enables Test-Driven Development (TDD). 
Provides rapid development for developing 
ASP.NET 
in Visual Studio. 
Supports IIS backend code for enhanced 
functionality. 
Provides clean separation of concerns(SoC) 
between different components.
Enhanced Software Quality 
ASP.NET MVC supports the following features for 
quality: 
– Security – Has built-in security. 
– Extensibility – many extensible frameworks. 
– Testability – supports unit testing
What is TDD? 
Test-Driven Development (TDD) is a software 
development process that relies on the 
repetition of a very short development cycle 
by utilizing automated test cases that defines 
new functionality and programming to the passing 
these tests.
Installation 
We can use the 
http://www.microsoft.com/web/downloads/platform.aspx
Through the web installer 
We can install some pieces to use through WPI: 
– SQL Express LocalDB Edition 11.0 for data 
– Visual Studio Express 2012 for coding 
– ASP.NET MVC 4 the framework 
– IIS Express for running and deployment
Creating a MVC 4 project
There are several templates
The Empty template 
The Empty template does not generate any sample 
models and controllers:
The Basic template 
The Basic template does not generate any sample 
models and controllers, but some starter pages:
The Internet template 
The Internet template now offers basic account views, 
controllers and models, that can be plugged into a database.
Internet template tests 
The Internet template now offers Unit testing into its home 
controller as well that was generated.
The Intranet template 
The Intranet template is similar to the Internet template, 
except it is gearing its authentication towards Windows 
authentication. There are no separate account pieces, 
but a readme.txt describing how to setup authentication in IIS.
Internet basic 
walkthrough 
Sept 06, 2014 
By Rich Helton
The Internet template 
Lets start with an application that we call InternetMVC4App:
Running the App 
Running the app from Visual Studio already gives us pieces:
Its all about routing 
We will route through the pages, the route begins with the 
RouteConfig.cs, this defines the starting action to be the 
Index function in the HomeController.cs:
Controllers are always first 
The Controller function is first, in this case, the Index function 
that returns values, in the form of models, for the pages. 
A controller can take in a HTTP request or model as needed.
Controllers call Views 
The Controller will call views, here we have a layout for all 
pages that put in the scripts.
Starting a Register 
Clicking on the Register link will bring us to the register 
function 
in the AccountController.cs by the link 
<li><a href="/Account/Register" id="registerLink">Register</a></li>
Register Controller 
The link will call the Register function: 
Which in turn will call the Register View:
Register View 
The Register View will populate the RegisterModel with 
username and password to pass to a Register function 
with the model:
Register Model 
The associated RegisterModel, notice the data annotations 
to provide validation on the data:
Register data annotation 
The data annotation ensures that the password is at 
least 6 characters:
Register function note 
After a successful register, we will be logged in by way of the 
Register(RegisterModel model). 
This is an HttpPost from the page, meaning data is posted.
Just a touch of Controller 
security 
Did you notice the [ValidateAntiForgeryToken], which is 
available functionality to block cross-site request forgeries 
and raise an error if the cookie value doesn't match the form 
value. 
There is a lot of security and validation functionality 
that MVC 4 provides.
The membership 
Within the App_Data directory of this project is an MDF 
data file that contains the basic tables for registration. 
The values will be added as usernames are added:
Defining the default 
connection 
Within the Web.config is where many of the configurations 
are defined, including the DefaultConnection connection 
string:
Setting the 
Membership 
database 
Sept 06, 2014 
By Rich Helton
Run aspnet_regsql.exe 
Navigate to the following directory on the server: 
C:WindowsMicrosoft.NETFrameworkv4.0.30319. 
Locate "aspnet_regsql.exe", right click and run as 
administrator.
Select the SQLExpress DB 
We can select the local DB of SQLExpress.
The aspnetdb is created 
An aspnetdb database will be created to store users and roles.
Change the connection string 
We modify the connection string in web.config to point 
at SQLEXPRESS. See 
http://msdn.microsoft.com/en-us/ 
library/jj653752(v=vs.110).aspx
Register the user again 
We need to add a user to the new tables through the 
registration process.
The user is added in 
SQLEXPRESS 
The new user is added to SQLExpress.
Adding Controllers 
Sept 06, 2014 
By Rich Helton
So far... 
Just a note, that so far, we have done almost no coding 
for our solution, but we have functionality for users and 
registration, as well as some basic pages.
We can add various 
components 
We can add specific components using Visual Studio wizards 
for Views and Controllers.
Adding a controller 
We get several templates to chose from when adding a 
controller
Controller Templates 
 Empty MVC controller 
 MVC controller with read/write actions and views, 
using Entity Framework 
 MVC controller with empty read/write actions 
 Empty API controller 
 API controller with read/write actions and views, 
using Entity Framework 
 API controller with empty read/write actions
Empty controller 
Just provides an Index() action
MVC read/write actions 
Provides Index(), Create(), Edit(), and Delete() actions.
MVC with entities 
We need to have an EF dbcontext and models define. 
See 
http://www.slideshare.net/rhelton_1/entity-frameworks101
Address Table entity model 
We add an Address table
MVC Entity Controller 
We can now use the Controller with entities
MVC read/write actions with 
entities 
Provides Index(), Create(), Edit(), and Delete() actions, 
now with an Address table in these functions.
Showing the access to the 
Address table 
We can see the Address table being accessed in the actions.
Views were added 
Views to match these actions to return the entities were 
added by default
We can add the 
MVCEntities... 
We can add these views that were created to the 
_Layout.cshtml.
Which will add to the layout 
The _Layout.cshtml will show the link.
The Index page 
This Index page that was generated is already functional that 
we see when clicking the link. We didn't code much for this.
Empty WebApi controller 
The empty web API controller will create a controller derived 
from the ApiController, which returns serialized data, 
such as a string, instead of the Controller interface which 
returns action results for views.
API controller with 
read/writes 
This will create a sample template for Get(), Put(), Post( ), 
and Delete() functions using strings.
API controller with entity 
read/writes 
This will create a sample, based on the entity selected, 
the template for Get(), Put(), Post( ), and Delete() functions 
using the entity, in this case the Address.
So far.... 
So far, we have added a lot of controllers, 
some who connect and pull data from the database. 
We still haven't coded much.
Adding Views 
Sept 06, 2014 
By Rich Helton
We can add Views 
We can create a view to automatically 
populate with a template of a model for various actions...
Views 
When we create the view, 
it is just the view, and 
while it may put model information in the view, 
the controller still has to be created to match the view.
Done for now, more 
to follow 
Sept 06, 2014 
By Rich Helton

Weitere ähnliche Inhalte

Was ist angesagt?

C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 
Spring hibernate tutorial
Spring hibernate tutorialSpring hibernate tutorial
Spring hibernate tutorialRohit Jagtap
 
Spring IOC advantages and developing spring application sample
Spring IOC advantages and developing spring application sample Spring IOC advantages and developing spring application sample
Spring IOC advantages and developing spring application sample Sunil kumar Mohanty
 
Building web applications with Java & Spring
Building web applications with Java & SpringBuilding web applications with Java & Spring
Building web applications with Java & SpringDavid Kiss
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherEdureka!
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCJohn Lewis
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorialRohit Gupta
 
Different Types of Containers in Spring
Different Types of Containers in Spring Different Types of Containers in Spring
Different Types of Containers in Spring Sunil kumar Mohanty
 

Was ist angesagt? (20)

C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 
Spring hibernate tutorial
Spring hibernate tutorialSpring hibernate tutorial
Spring hibernate tutorial
 
Spring IOC advantages and developing spring application sample
Spring IOC advantages and developing spring application sample Spring IOC advantages and developing spring application sample
Spring IOC advantages and developing spring application sample
 
Building web applications with Java & Spring
Building web applications with Java & SpringBuilding web applications with Java & Spring
Building web applications with Java & Spring
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring core
Spring coreSpring core
Spring core
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Spring aop
Spring aopSpring aop
Spring aop
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features Together
 
Mongo db
Mongo dbMongo db
Mongo db
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
CodeIgniter 101 Tutorial
CodeIgniter 101 TutorialCodeIgniter 101 Tutorial
CodeIgniter 101 Tutorial
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Different Types of Containers in Spring
Different Types of Containers in Spring Different Types of Containers in Spring
Different Types of Containers in Spring
 

Ähnlich wie AspMVC4 start101

Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Rich Helton
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend FrameworkJuan Antonio
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Akhil Mittal
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web MahmoudOHassouna
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLAkhil Mittal
 
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5  Building Your First Web Application (A Beginner S GuideASP.NET MVC 5  Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5 Building Your First Web Application (A Beginner S GuideAlicia Buske
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To MvcVolkan Uzun
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introductionCommit University
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)M Ahsan Khan
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC eldorina
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMahmoudOHassouna
 

Ähnlich wie AspMVC4 start101 (20)

Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
MVC 4
MVC 4MVC 4
MVC 4
 
Mvc summary
Mvc summaryMvc summary
Mvc summary
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
ASP.NET Identity
ASP.NET IdentityASP.NET Identity
ASP.NET Identity
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
 
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5  Building Your First Web Application (A Beginner S GuideASP.NET MVC 5  Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
MVC Training Part 2
MVC Training Part 2MVC Training Part 2
MVC Training Part 2
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVC
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 

Mehr von Rich Helton

NServicebus WCF Integration 101
NServicebus WCF Integration 101NServicebus WCF Integration 101
NServicebus WCF Integration 101Rich Helton
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce IntroRich Helton
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in AndroidRich Helton
 
Python For Droid
Python For DroidPython For Droid
Python For DroidRich Helton
 
Spring Roo Rev005
Spring Roo Rev005Spring Roo Rev005
Spring Roo Rev005Rich Helton
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalRich Helton
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall introRich Helton
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security ClassRich Helton
 
Secure Ftp Java Style Rev004
Secure Ftp  Java Style Rev004Secure Ftp  Java Style Rev004
Secure Ftp Java Style Rev004Rich Helton
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 

Mehr von Rich Helton (15)

NServicebus WCF Integration 101
NServicebus WCF Integration 101NServicebus WCF Integration 101
NServicebus WCF Integration 101
 
Salesforce Intro
Salesforce IntroSalesforce Intro
Salesforce Intro
 
First Steps in Android
First Steps in AndroidFirst Steps in Android
First Steps in Android
 
NServiceBus
NServiceBusNServiceBus
NServiceBus
 
Python For Droid
Python For DroidPython For Droid
Python For Droid
 
Spring Roo Rev005
Spring Roo Rev005Spring Roo Rev005
Spring Roo Rev005
 
Python Final
Python FinalPython Final
Python Final
 
Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 Final
 
Jira Rev002
Jira Rev002Jira Rev002
Jira Rev002
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall intro
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security Class
 
Secure Ftp Java Style Rev004
Secure Ftp  Java Style Rev004Secure Ftp  Java Style Rev004
Secure Ftp Java Style Rev004
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 

Kürzlich hochgeladen

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 

Kürzlich hochgeladen (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

AspMVC4 start101

  • 1. C# ASP.NET-MVC4 Frameworks 101 Sept 06, 2014 By Rich Helton
  • 2. ASP.NET MVC Is Microsoft's framework in support of the Model-View-Controller, the most popular design pattern in the world for rapid development. Entity Frameworks are used heavily with ASP.NET MVC, but they are a completely separate framework that are used independently as well.
  • 4. ASP.NET MVC benefits Enables Test-Driven Development (TDD). Provides rapid development for developing ASP.NET in Visual Studio. Supports IIS backend code for enhanced functionality. Provides clean separation of concerns(SoC) between different components.
  • 5. Enhanced Software Quality ASP.NET MVC supports the following features for quality: – Security – Has built-in security. – Extensibility – many extensible frameworks. – Testability – supports unit testing
  • 6. What is TDD? Test-Driven Development (TDD) is a software development process that relies on the repetition of a very short development cycle by utilizing automated test cases that defines new functionality and programming to the passing these tests.
  • 7. Installation We can use the http://www.microsoft.com/web/downloads/platform.aspx
  • 8. Through the web installer We can install some pieces to use through WPI: – SQL Express LocalDB Edition 11.0 for data – Visual Studio Express 2012 for coding – ASP.NET MVC 4 the framework – IIS Express for running and deployment
  • 9. Creating a MVC 4 project
  • 10. There are several templates
  • 11. The Empty template The Empty template does not generate any sample models and controllers:
  • 12. The Basic template The Basic template does not generate any sample models and controllers, but some starter pages:
  • 13. The Internet template The Internet template now offers basic account views, controllers and models, that can be plugged into a database.
  • 14. Internet template tests The Internet template now offers Unit testing into its home controller as well that was generated.
  • 15. The Intranet template The Intranet template is similar to the Internet template, except it is gearing its authentication towards Windows authentication. There are no separate account pieces, but a readme.txt describing how to setup authentication in IIS.
  • 16. Internet basic walkthrough Sept 06, 2014 By Rich Helton
  • 17. The Internet template Lets start with an application that we call InternetMVC4App:
  • 18. Running the App Running the app from Visual Studio already gives us pieces:
  • 19. Its all about routing We will route through the pages, the route begins with the RouteConfig.cs, this defines the starting action to be the Index function in the HomeController.cs:
  • 20. Controllers are always first The Controller function is first, in this case, the Index function that returns values, in the form of models, for the pages. A controller can take in a HTTP request or model as needed.
  • 21. Controllers call Views The Controller will call views, here we have a layout for all pages that put in the scripts.
  • 22. Starting a Register Clicking on the Register link will bring us to the register function in the AccountController.cs by the link <li><a href="/Account/Register" id="registerLink">Register</a></li>
  • 23. Register Controller The link will call the Register function: Which in turn will call the Register View:
  • 24. Register View The Register View will populate the RegisterModel with username and password to pass to a Register function with the model:
  • 25. Register Model The associated RegisterModel, notice the data annotations to provide validation on the data:
  • 26. Register data annotation The data annotation ensures that the password is at least 6 characters:
  • 27. Register function note After a successful register, we will be logged in by way of the Register(RegisterModel model). This is an HttpPost from the page, meaning data is posted.
  • 28. Just a touch of Controller security Did you notice the [ValidateAntiForgeryToken], which is available functionality to block cross-site request forgeries and raise an error if the cookie value doesn't match the form value. There is a lot of security and validation functionality that MVC 4 provides.
  • 29. The membership Within the App_Data directory of this project is an MDF data file that contains the basic tables for registration. The values will be added as usernames are added:
  • 30. Defining the default connection Within the Web.config is where many of the configurations are defined, including the DefaultConnection connection string:
  • 31. Setting the Membership database Sept 06, 2014 By Rich Helton
  • 32. Run aspnet_regsql.exe Navigate to the following directory on the server: C:WindowsMicrosoft.NETFrameworkv4.0.30319. Locate "aspnet_regsql.exe", right click and run as administrator.
  • 33. Select the SQLExpress DB We can select the local DB of SQLExpress.
  • 34. The aspnetdb is created An aspnetdb database will be created to store users and roles.
  • 35. Change the connection string We modify the connection string in web.config to point at SQLEXPRESS. See http://msdn.microsoft.com/en-us/ library/jj653752(v=vs.110).aspx
  • 36. Register the user again We need to add a user to the new tables through the registration process.
  • 37. The user is added in SQLEXPRESS The new user is added to SQLExpress.
  • 38. Adding Controllers Sept 06, 2014 By Rich Helton
  • 39. So far... Just a note, that so far, we have done almost no coding for our solution, but we have functionality for users and registration, as well as some basic pages.
  • 40. We can add various components We can add specific components using Visual Studio wizards for Views and Controllers.
  • 41. Adding a controller We get several templates to chose from when adding a controller
  • 42. Controller Templates  Empty MVC controller  MVC controller with read/write actions and views, using Entity Framework  MVC controller with empty read/write actions  Empty API controller  API controller with read/write actions and views, using Entity Framework  API controller with empty read/write actions
  • 43. Empty controller Just provides an Index() action
  • 44. MVC read/write actions Provides Index(), Create(), Edit(), and Delete() actions.
  • 45. MVC with entities We need to have an EF dbcontext and models define. See http://www.slideshare.net/rhelton_1/entity-frameworks101
  • 46. Address Table entity model We add an Address table
  • 47. MVC Entity Controller We can now use the Controller with entities
  • 48. MVC read/write actions with entities Provides Index(), Create(), Edit(), and Delete() actions, now with an Address table in these functions.
  • 49. Showing the access to the Address table We can see the Address table being accessed in the actions.
  • 50. Views were added Views to match these actions to return the entities were added by default
  • 51. We can add the MVCEntities... We can add these views that were created to the _Layout.cshtml.
  • 52. Which will add to the layout The _Layout.cshtml will show the link.
  • 53. The Index page This Index page that was generated is already functional that we see when clicking the link. We didn't code much for this.
  • 54. Empty WebApi controller The empty web API controller will create a controller derived from the ApiController, which returns serialized data, such as a string, instead of the Controller interface which returns action results for views.
  • 55. API controller with read/writes This will create a sample template for Get(), Put(), Post( ), and Delete() functions using strings.
  • 56. API controller with entity read/writes This will create a sample, based on the entity selected, the template for Get(), Put(), Post( ), and Delete() functions using the entity, in this case the Address.
  • 57. So far.... So far, we have added a lot of controllers, some who connect and pull data from the database. We still haven't coded much.
  • 58. Adding Views Sept 06, 2014 By Rich Helton
  • 59. We can add Views We can create a view to automatically populate with a template of a model for various actions...
  • 60. Views When we create the view, it is just the view, and while it may put model information in the view, the controller still has to be created to match the view.
  • 61. Done for now, more to follow Sept 06, 2014 By Rich Helton