SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
Â
ASP.NET MVC Zero to Hero Guide
1. ASP.NET MVC Zero to Hero
Md. Mahedee Hasan
Microsoft MVP , Visual Studio and Development Technologies
Senior Software Architect, Leadsoft Bangladesh Limited
Trainer, Leads Training and Consulting Limited
Microsoft Community Contributor
Blog: http://mahedee.net
MVP | Software Architect | Trainer | Technical Blogger | MCTS
1
2. MAHEDEE.NET
2
Introduction to .NET
What is Microsoft .NET?
Another Programming Language?
.NETFramework
Programming Languages
C#, Visual Basic, C++, J# etc.
Markup Languages
HTML, XML etc.
Software development platform
Language neutral
Framework is a basic
or essential
supporting structure
of a system
A
framework
4. MAHEDEE.NET
4
ASP.NET
ASP â Active Server Page
Asp.net is an open source server-side web application framework
Designed for Web development to produce dynamic Web pages
Introduced in 1998
Introduction
5. MAHEDEE.NET
5
ASP.NET
ASP.NET is a new ASP generation.
ASP.NET pages are compiled, which makes them faster
Normally written in VB (Visual Basic) or C# (C sharp).
Introduction âŚ
7. MAHEDEE.NET
7
ASP.NET Web form
Support multiple languages
Improved performance
Control-based, event-driven execution model
More productive
Allows clean cut code
12. MAHEDEE.NET
12
Why .NET? âŚ
.NET developers are one of the highest paid
associates
Yearly Income (India) Rs. 334,959 per year [1]
Ref: 1. https://www.youtube.com/watch?v=auErLqIJY2M
Highest paid .NET developers
ASP.NET MVC Developers IIS Administrator
13. MAHEDEE.NET
13
Average salary for .NET developers
International Market $45,569 ~ $103,575 per year [1]
Salary in Bangladesh
1. http://www.payscale.com/research/US/Job=.NET_Software_Developer_%2F_Programmer/Salary
2. http://www.salaryexplorer.com/salary-survey.php?loc=18&loctype=1&job=781&jobtype=3
14. MAHEDEE.NET
14
Job condition in market places
Lots of works
for .NET
developers
Specially for
asp.net
Many Bangladesh
Freelancer work in
.NET platform
.NET developers
are mostly top
rated
Comparatively
large project
19. MAHEDEE.NET
19
Future of .NET âŚ
.NET can be used to build
AR/VR application using
unity
Tizen allows .net
developers to build app in
Samsung devices including
Tvs and mobile
21. MAHEDEE.NET
21
Future of .NET
Is an independent organization
To improve open source software development and
collaboration around the .net framework
23. MAHEDEE.NET
23
What is ASP.NET MVC?
It is Software Architectural pattern
Software Architectural
Pattern
Software
Design Pattern
Run on ASP.NET Framework
26. MAHEDEE.NET
26
What is View Engine?
Rendering HTML from views to the browser.
View
Engine
Razor
Traditional
ASPX
Spark
Nhaml
etc
Razor is a markup
language embed with
server-based code
30. MAHEDEE.NET
30
Controller
Controllers are classes that handle incoming browser requests
Retrieve data, and then specify view templates and return a
response to the browser
MVC requires the name of all controllers to end with "Controller"
Controller classes inherited from Controller base class
The Controllers Folder contains the controller classes
31. MAHEDEE.NET
31
Action and Parameters
Action is a public method
The controller defines action methods
Controllers can include as many action methods as needed
Action methods typically have a one-to-one mapping with user
interactions
Can take one or more parameter
36. MAHEDEE.NET
37
Annotation
Annotation is a configuration option of the domain class
Key
ForeignKey
NotMapped
StringLength
Timestamp
ConcurrencyCheck
Table
Index
Required
MinLength
MaxLength
Database Schema
related Attributes
Validation Attributes
44. ⢠How affect in performance?
â Create pdb (program database â uses for debugging) files which
creates extra overhead.
â For this reason you may face timeout problem.
⢠Best Practice
â Always prepare release in release mode.
MAHEDEE.NET
46
Prepare release with release mode
45. ⢠By default debug=âtrueâ when you create a web application.
⢠It is necessary to set debug=âtrueâ in development
environment.
⢠How affect in performance?
â If you set debug = âtrueâ, application requires the pdb
information to be inserted into the file
â So results in a comparatively larger file and hence processing will
be slow.
MAHEDEE.NET
47
In Web.Config, Set debug=âfalseâ
46. ⢠Best Practice
â In deployment server, set debug = âfalseâ in web.config
<system.web>
<compilation debug="false" targetFramework="4.5.1" />
</system.web>
MAHEDEE.NET
48
In Web.Config, Set debug=âfalseâ
47. ⢠Trace the application to monitor the executions of
application or a pages
⢠Uses for diagnostic purpose
⢠How affect in performance?
â Loaded extra information to the pages which degrades
performances.
MAHEDEE.NET
49
Turn off Tracing unless until required
48. ⢠Best Practice
â Always set trace enabled = âfalseâ unless or until you required to
monitor a pageâs executions
<system.web>
<trace enabled="true" pageOutput="true" requestLimit="10"
localOnly="false" mostRecent="true" traceMode="SortByTime"/>
</system.web>
MAHEDEE.NET
50
Turn off Tracing unless until required
49. ⢠Though, ASP.NET manages session state by default, we must
pay attention of session memory management.
⢠How affect in performance?
â When you store your data in in-process or on a state server or in
a SQL Database, it requires memory.
â It is also time consuming when you store or retrieve data in-
process or state server or SQL server.
MAHEDEE.NET
51
Carefully manage session state
50. ⢠Best Practice
â If your page is static, it is recommended not to use session state.
In such cases where you donât need to use session state, disable it
on your web form using the following directive:
<@%Page EnableSessionState="false"%>
â In case you use the session state only to retrieve data and not to
update, make the session state read-only using the following
directive.
<@%Page EnableSessionState ="ReadOnly"%>
â Consider carefully whether there is a need of the state server or
SQL Server mode.
MAHEDEE.NET
52
Carefully manage session state âŚ
51. ⢠Best Practice
â SQL Server session mode provides lower performance than state
server mode.
â Try to avoid keeping object in session. Since it requires serializing
then de-serializing which affected in performance.
â Use client-side state management than server side.
MAHEDEE.NET
53
Carefully manage session state âŚ
52. ⢠View State provides page level state management
⢠As long as the user is on the current page, state is available
and the user redirects to the next page and the current page
state is lost
⢠View State can store any type of data because it is object
type but it is preferable not to store a complex type of data
due to the need for serialization and deserialization on each
post back
MAHEDEE.NET
54
Disable View State of a page if not required
53. ⢠How affect in performance?
â It increases the total payload of a page when submitted and
when serving request.
â Serialization and deserialization of the data is required when
submitting data and gets requested data.
⢠Best Practice
â Pages that do not have any server postback events can have the
view state turned off.
â The default behaviour of the View State property is enabled, but
if you donât need it, you can turn it off at the control or page
level.
<%@ Page EnableViewState="false" %>
MAHEDEE.NET
55
Disable View State of a page if not required
54. ⢠Finally block executes whether any exception occurs or not.
⢠How affect in performance?
â Sometimes application occupy resources where as it doesnât
need it.
⢠Best Practice
â Always use a finally block to release resources like closing
database connections, closing files, disposing objects etc.
MAHEDEE.NET
56
Use finally block to release resources
55. ⢠To show huge number of data in gridview, we cannot think
general way because it takes huge time to load.
⢠Best Practice
â To load grid view faster take advantages of paging, it shows small
subsets of data at a time.
â JQGrid is faster than asp.net grid view because it does
everything in client side.
MAHEDEE.NET
57
Use paging in grid view
56. ⢠How affect in performance?
â The uses of web server controls increase the response time.
â Web server controls go to the server executes all of its life cycle
and then rendered on the client side.
⢠Best Practice
â Donât use server control unless until required.
â Use HTML elements where suited.
MAHEDEE.NET
58
Minimizes number of web server control