Customizing Controllers Controllers Customizing කර ගැනීම

Slides:



Advertisements
Similar presentations
Using EBSCOs Search Box Builder Tool Tutorial. Would you like to promote your EBSCOhost resources by adding an easy-to-use search box to your website?
Advertisements

Creating an EDS Search Box Using EBSCO’s Search Box Builder Tool
METALOGIC s o f t w a r e © Metalogic Software Corporation DACS Developer Overview DACS – the Distributed Access Control System.
Don’t get Stung (An introduction to the OWASP Top Ten Project) Barry Dorrans Microsoft Information Security Tools NEW AND IMPROVED!
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
ASP MVC s/mvc-4/getting-started-with- aspnet-mvc4/intro-to-aspnet- mvc-4.
Virtual techdays INDIA │ November 2010 ASP.Net MVC Deep Dive Sundararajan S │ Associate Tech Architect, Aditi Technologies.
Troubleshooting Federation, AD FS 2.0, and More…
Fraser Technical Solutions, LLC
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua.NET/Cloud Computing UG Lead Blog:
ASP.NET Web Server Controls Basic Web Server Controls.
Standalone Java Application vs. Java Web Application
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Building Secure Web Applications With ASP.Net MVC.
BIT 286: Web Applications Lecture 10 : Thursday, February 5, 2015 ASP.Net Form Submission.
Module 7: Advanced Application and Web Filtering.
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -

1 Using MVC 6. MVC vs. ASP Web Forms Both run under ASP.NET Can coexist In Web Forms, browser requests page. xxx.aspx and xxx.aspx.cs on the server Page.
Build Data Driven Apps with ASP.NET Core Rachel Appel.
ArcGIS for Server Security: Advanced
Jim Fawcett CSE686 – Internet Programming Spring 2014
An introduction to ASP.Net with MVC Nischal S
Receiving form Variables
Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals Wikis are collections of searchable,
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Selenium and Selenium on Rails
Building Web Applications with Microsoft ASP
Jim Fawcett CSE686 – Internet Programming Spring 2012
z/Ware 2.0 Technical Overview
C#: ASP.NET MVC Overview
Node.js Express Web Services
SharePoint Cloud hosted Apps
04 | Customizing Controllers
02 | Developing ASP.NET MVC 4 Models
පාඨමාලා මාතෘකා Microsoft SQL Server Databases සැකසීම
Introduction to Programming with Python
Data Structures and Database Applications Custom Models with MVC
Introduction to Programming with Python
Introduction to Programming with Python
Introduction to Programming with Python
Controllers.
Customizing Views Views Customize කර ගැනීම
Introduction to ASP.NET MVC ASP.NET MVC පෙරවදන
ETI Base Code ETI මුලධර්මයන් හදුනාගනිමු
Introduction to Authentication Authentication සදහා හැදින්වීම
මුහම්මද් සල්ලල්ලාහු අලෙයිහි වසල්ලම්
Basics of MVC MVC වල මුලික කොටස්
Social Media And Global Computing Managing MVC with Custom Models
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
Creating and Configuring Models Models create කිරීම සහ config කර ගැනීම
Using Visual Studio Visual Studio භාවිතය
වී පොහොර සහනාධාර මුදල් ප්‍රදාන වැඩසටහන 2017/18 මහ කන්නය
05 | Customizing Views Jon Galloway | Development Platform Evangelist
Introduction to Programming with Python
Introduction to Programming with Python
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
Introduction to Programming with Python
Introduction to Programming with Python
MVC Controllers.
මොඩියුල විශ්ලේෂණය Stored Procedure හඳුන්වා දීම.
ASP.NET MVC Web Development
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Customizing Controllers Controllers Customizing කර ගැනීම Module Omal Perera | http://www.windowsgeek.lk @omalperera Microsoft Virtual Academy

Module Overview Actions Add කර ගැනීම Model Binding Filters Vanity URLs Controller Best Practices

Actions Add කර ගැනීම Module 3 Microsoft Virtual Academy

Actions Add කර ගැනීම Controller එකක් කියන්නේ class එකක් Action එකක් කියන්නේ method එකක් Action එකක් create කරනවා කියන්නේ සරලවම, class එකකට method එකක් add කිරීමකට.

Action Signature Parameters Return Types Normal parameters MVC model binding Return Types ActionResult FileResult JsonResult ViewResult

Get සහ Post Create/Update/Delete සදහා පියවර දෙකක් ඇත Present the form Accept the input Create two actions Form presentation via HttpGet (default) Accept data via HttpPost

Model Binding Update an action to use FormCollection Execute and show off generated form (with name attributes) Show via debugger the generated form collection Highlight id vs name Model Binding

Model Binding Module 3 Microsoft Virtual Academy

Default Model Binder Input elements වල name attribute එක පාවිච්චි කරයි Simple data types සදහා automatically parameter names match කර ගනී. Complex objects වලදී property name එකෙන් map කර ගනී. dotted notation <input type="text" name="Album.LinerNotes" /> Song SongID Title Length Lyrics Album AlbumID Title Label LinerNotes

Model Binding control කිරීම Need සියලු දේ edit කල හැකි විදියට form එකක් create කර ගැනීමට අවශ්‍යයි. නමුත් lyrics ඒ form එකේ අඩංගු නොවිය යුතුයි Challenge Default model binder එක මගින් automatically සියලුම inbound properties bind කර ගනී Song SongID Title Length Lyrics

විසදුම සරලවම අනෙකුත් විසදුම් Bind කල යුතු properties indicate කිරීමට bindattribute එක use කරන්න Edit([Bind(Include = "SongID,Title,Length")] Song song) අනෙකුත් විසදුම් view model එකක් create කර ගැනීම

BindAttribute

Filters Module 3 Microsoft Virtual Academy

Filters Filters කියන්නේ attribute වර්ගයක් controllers සහ actions වලට informations add කරන්න use කරනවා Goal : Execution වෙන ආකාරය වෙනස් කරනවා Security config කරන්න පුළුවන් built-in filters රාශියක් MVC සමග පැමිණෙනවා

Normal Action Execution MVC Instantiates Controller User Request Action is Executed HTML Returned Model is Combined with View

Actions with Filters MVC Instantiates Controller User Request Pre-execution Filter Code Executes Action is Executed HTML Returned Model is Combined with View Post-execution Filter Code Executes

Filters Add කරගැනීම Action Controller Global FilterConfig.cs

Security Filters Authorize ValidateAntiForgeryToken RequireHttps controller/actions access කරන usersලව control කිරීමට හැකි වීම Properties Users Roles ValidateAntiForgeryToken Defends against cross-site request forgery Requires anti-forgery token to be added to view RequireHttps SSL

SSL Traffic Encryptions සහ හානි අවම කරයි Authenticates server SSL use කල යුත්තේ කුමන වෙලාවටද? sensitive information ලබා දෙන විට After authentication http://blog.codinghorror.com/should-all-web-traffic-be-encrypted/

Security Filters

Vanity URLs Module 3 Microsoft Virtual Academy

Standard URL URL එක refer කරන දෙය ගැන usersලට අදහසක් නොමැති වීම www.mymusicstore.com/App/Album/Details/Display.aspx?ID=42&BandID=64 URL එක refer කරන දෙය ගැන usersලට අදහසක් නොමැති වීම URL එක refer කරන දෙය ගැන search engines සදහා අදහසක් ගනිඅමට අපහසු වීම

Vanity URL පගේ එකෙන් ලබා දෙන දෙය ගැන usersලට අදහසක් ගැනීමට හැකි වීම www.mymusicstore.com/Album/Cure/Wish පගේ එකෙන් ලබා දෙන දෙය ගැන usersලට අදහසක් ගැනීමට හැකි වීම Search engines සදහා පහසු වීම මේ නිසා vanity URLs ඉතාමත් වැදගත් වීම

MVC Routing Vanity URLs handle කරනු ලබන්නේ routing මගින් දෙනු ලබන URL එකකට අදාලව controller/action ඉදිරිපත් කිරීම, MVC වල routing විසින් කරනු ලබන දෙයක් Routing update කිරීමේ ක්‍රම RouteConfig.cs AttributeRouting

RouteConfig.cs

Attribute Routing Attributes මගින් routing/URL control කල හැක RouteAttribute [Route("Album/Edit/{id:int}")] public ActionResult Edit(int id) www.mymusicstore.com/Album/Edit/42 Edit action එක call කරයි Parameter එක මගින් ID එක pass කරයි ID එක int විය යුතුයි

RoutePrefix Controller එකට add කරයි Adds prefix to all routes [RoutePrefix("Album")] public class AlbumsController : Controller { [Route("Album/Edit/{id:int}")] public ActionResult Edit(int id) // code }

Attribute Routing

Controller Best Practices Module 3 Microsoft Virtual Academy

Controller Design Guidelines High Cohesion හැකි තරම් closely relate වෙන ආකාරයට actions create කරන්න Low Coupling Controllers should know as little about the rest of the system as possible Testings සහ changes පහසු කරයි Repository pattern Wrap data context calls into another object