Repository navigation
ASPNET Core 5 MVC Bootstrap Responsive Web Programming Lecture 3 More Controllers and Views
ASP.NET Core 5 - MVC - Bootstrap - Responsive Web Programming - Lecture 3 : More Controllers & Views
Full tutorial link > https://www.youtube.com/watch?v=F3C3xsIIK7s
#SoftwareDevelopment #Software #Engineering #CSharp #Coding #Course
Asp.NET Core V5 - MVC Pattern - Bootstrap V5 - Responsive Web #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnAWtgk4ja3HN3xgMKF7BOE
GitHub repository of the course : https://github.com/FurkanGozukara/Responsive-Web-Design-With-ASP.NET-5-and-MVC-Pattern-and-BootStrap-5-2021
Discord channel link of the course : https://discord.gg/6Mrb8MwteQ
How to use Discord : https://youtu.be/AEwPtYiLvsQ
In Lecture 3:
-
How to write a custom route path for default controller in an ASP.NET Core MVC application
-
How to call multiple different Views from single controller
-
What are actions of controllers and how to use actions
-
Different action results
-
How to return file or different HTTP status code from Views
-
How to do a redirect from View action calls
-
How pass data to the Views from controllers with Model or ViewData or ViewBag approaches
-
How to do null check to parse Model or ViewData in Views
-
How to use dynamic models in Views
-
What is the default compiler path checking of ASP.NET Core MVC
-
How to do form post with raw HTML and Razor syntax in Views
Please subscribe and make comments.
This course requires fundamental knowledge about programming and C#. So please watch our below playlists related to C#.
Our courses playlists are like below:
[1] Introduction to Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffskoSXySh0MdiayPJsBZ7m2o
[2] Advanced #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslHaBdS3RUW26RKzSjkl8m4
[3] Object Oriented Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnH3XJb66FDIHh1yHwWC26I
[4] Asp.NET Core V5 - MVC Pattern - Bootstrap V5 - Responsive Web #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnAWtgk4ja3HN3xgMKF7BOE
[5] Artificial Intelligence (AI) and Machine Learning (ML) Full Course with C# Examples playlist: https://www.youtube.com/playlist?list=PL_pbwdIyffskVschrADCL6KEnL_nqDtgD
[6] Software Engineering Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslgxMVyXhnHiSn_EWTvx1G-
[7] Security of Information Systems Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslM_o92NwkaUzD7C6Fekx26
[8] (Turkish) Bilgisayar Becerileri Tam Ders playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsmyE2e909ea1MXLcMb8MenG
auto subtitle timing : NA
-
00:00:01 Hello dear students. Welcome to the lecture 3 of responsive web design with asp.net 5
-
00:00:07 and then received pattern and bootstrap 5, so if you remember that we have left with
-
00:00:14 actions of controllers in the previous lecture. Also, I have noticed that there was a noise
-
00:00:24 caused by the relation of my microphone in the previous lecture. Hopefully it
-
00:00:31 Will be fixed in this lecture. I am sorry about that.
-
00:00:37 So I will start with copying our previous lecture source code and I will continue from
-
00:00:46 on that source code.
-
00:00:52 Okay.
-
00:00:57 Because I believe it is being more effective in this way.
-
00:01:09 So there were HTTP get HTTP post. We were able to Define which method can access the
-
00:01:18 which method also we could use same method name with different different access methodologies
-
00:01:30 such as HTTP get and you see edit and HTTP edit, but they are doing different things.
-
00:01:37 It is like method overloading.
-
00:01:42 Okay, so
-
00:01:50 let's start with renaming our solution and project.
-
00:02:02 Okay.
-
00:02:06 Okay, and let's run our application and continue with the next tutorial.
-
00:02:26 all right action results
-
00:02:27 in the previous article we discussed actions which are the methods defined on a controller
-
00:02:37 actions are invoked when a requested URL is matched to an action on a controller. This
-
00:02:42 is done by the routing system when the action method finishes it work. It will usually return
-
00:02:48 something to the client and that something will usually be implementing the I action
-
00:02:53 result interface or task less than I action result greater than if the method is asynchronous.
-
00:02:59 Okay suck.
-
00:03:01 I think this is pretty clear.
-
00:03:08 As soon as your controller inherits, the built-in base controller class Microsoft asked net
-
00:03:16 core MVC controller. We are supplied with a wide range of helper methods for generating
-
00:03:23 the response the action result an example of such a method has already been used in
-
00:03:28 this tutorial The View method it will take the matching view file and turn it into an
-
00:03:34 instance of the view result class which implements the I action result interface.
-
00:03:39 After that asp.net MVC will automatically transform it into a response to the browser
-
00:03:45 in this case in the form of an okay status code and then a body of HTML.
-
00:03:51 A view is far from the only possible result of a controller action though since the result
-
00:03:58 will eventually be returned to a browser the available methods should cover all possible
-
00:04:02 outcomes of HTTP requests. So a controller action can of course also result in a redirect
-
00:04:08 a 404 page not found or any of the other HTTP status codes. Here's an incomplete list of
-
00:04:16 the most interesting and useful methods for generating an action result.
-
00:04:20 Okay, so there are several action results and let's test each of them to have a better
-
00:04:32 idea.
-
00:04:33 And what I'm going to do is
-
00:04:40 I will add some new index pages to test them. For example, let's say content, okay.
-
00:04:50 So I will be using same home controller, but I will return different weaves. Okay?
-
00:05:02 So let's add a video of name with us. Okay Reserve even rows or MTV.
-
00:05:12 I think I will pitch Resort.
-
00:05:16 We let's add some sort of even see the difference.
-
00:05:23 Okay, and the name will be
-
00:05:29 Content we've by the way content actually returns a taste of we don't need a V4 that
-
00:05:36 or so I will name this as a general each example returns, okay.
-
00:05:47 You see there is some templates models created a details edit empty list. I will make it
-
00:06:01 empty model.
-
00:06:07 Okay, so first and start with content example, and my we are waiting.
-
00:06:19 Visual Studio to at Live to our application
-
00:06:37 He's really taking a lot of time.
-
00:06:56 Sokka
-
00:06:58 oh we have an answer is interesting. That's that.
-
00:07:08 mtbf
-
00:07:09 and I will name it as example.
-
00:07:20 Okay examples.
-
00:07:23 You see it is reserve you empty and it's meanwhile, do it started immediately. Okay, it's fine.
-
00:07:32 So in the home controller, whatever I am going to do is
-
00:07:41 Right different methods. So let's write a method for example of content. Okay.
-
00:07:54 Content example in this case. It will return a Content. So we already had that but I will
-
00:08:03 leave it like this and
-
00:08:10 We teach text equal to okay something like this. So how we will be able to access it.
-
00:08:17 We didn't Define any access methods.
-
00:08:21 So let's try it.
-
00:08:29 It will open index see HTML by default.
-
00:08:35 Okay, so home and content examples.
-
00:08:47 You see it's working and then I will provide.
-
00:08:52 some texts such as
-
00:08:54 yes, you see when I provide a variable name as Hazard text with the get method it is working.
-
00:09:08 Can I do this video post method as well?
-
00:09:13 So let's try it, too.
-
00:09:17 and I think we had some post method example, but
-
00:09:25 I can see it. Why?
-
00:09:33 Okay, so it wasn't lecture one maybe.
-
00:09:52 Okay, this is not here. So.
-
00:10:15 Okay, so begin for we don't have it or we have the example okay here and so let's make
-
00:10:29 another example. So this this time we will be accessing the method of content example.
-
00:10:39 Here it will be in the home controllers and metals will be paused and value will be test
-
00:10:52 of content example. You see the hidden value name is as our name and
-
00:10:59 okay, let's restart.
-
00:11:05 So you see we are this is the format of defining a mixed or race or scientists having a post
-
00:11:17 in.
-
00:11:18 Asp.net MVC. However, we could do this with I believe Ralph HTML as well. I will do that
-
00:11:29 too. So let's first see that.
-
00:11:31 Okay, it is working and I would write the same with HTML form.
-
00:11:44 Okay, I think there is.
-
00:11:48 Okay.
-
00:11:49 If I remember correctly, let me check.
-
00:12:02 I can't remember this because it was a long time since I have ridden.
-
00:12:14 I think we have to have some value around.
-
00:12:25 or here
-
00:12:26 Okay. Okay. So the action will be in index then I think it will be first home then index
-
00:12:44 then content example. We don't have a pH p-- or such. Yeah, and
-
00:12:51 yeah, then we will have an input which name?
-
00:13:04 So the name going to be this you don't need ID. You can remove it the type of the text
-
00:13:10 value will be lets say test of a bitch HTML form, okay.
-
00:13:19 Then we will have a submit button and submit type submit' value will be.
-
00:13:34 Okay, so you see which undefined a deal with razor scientists or with regular HTML both
-
00:13:43 should work and let's try this version as well.
-
00:13:52 Are we having an extra thing here, but it wasn't necessarily what?
-
00:14:00 Whatever we can remove it later.
-
00:14:04 Okay, we can test our URL is correct or not with home index. Yeah, it's correct. So this
-
00:14:16 is equal to this because of the rotating and here.
-
00:14:22 Okay submit form which classic HTML. This is oh, it doesn't work. Obviously.
-
00:14:35 Because y home in this content example.
-
00:14:43 Okay, why because we didn't Define form type, perhaps what interesting?
-
00:14:54 Form action, maybe we need to define the method post. Okay, let's retry.
-
00:15:03 Moths. This also gave me some idea to test something as well whether it is true or not.
-
00:15:17 I will show you that as well. Okay, so let's retry.
-
00:15:24 home index content examples
-
00:15:27 What is the difference let's check the source code? Okay home content example and home index
-
00:15:33 won't enter. Okay, so you see the URL we have provided was incorrect. I will remove it.
-
00:15:39 Okay Taste of both of the rotational form post method. Okay?
-
00:15:52 Then I will have get method as well so we can see the difference.
-
00:15:59 Okay, let's read on we have pixie to URL.
-
00:16:09 Okay, it looks like our salt.
-
00:16:18 Automatic formatting had added some unnecessary lines. I will just
-
00:16:30 FaceTime
-
00:16:32 All right, open it. So let's try submit.
-
00:16:44 Okay, so this value is also being displayed. This is
-
00:16:50 Wrong and I we can fix that you see this is input type text. However, we want these to
-
00:16:57 be input type hidden' not text. You don't want it to be visible and let's adhere some.
-
00:17:08 HR HR also, maybe some formatting such as div style and
-
00:17:16 Center yeah.
-
00:17:18 Take him aside here. We can also add some padding perhaps.
-
00:17:29 Okay, let's please try.
-
00:17:43 The type of the input does matter which type of input you are sanding when you make it
-
00:17:49 hidden, it won't be visible in the browser. However, of course from source code you can
-
00:17:57 see so this is the submit form. Okay. So this is the result we are getting in-home content
-
00:18:03 example page as you can see product updated with text equal to test point and example
-
00:18:10 with HTML form post method and
-
00:18:12 We do the other one you see now it is visible in the URL because it is done with the get
-
00:18:19 method. However, we get the same result because our method supports board. However, if I make
-
00:18:30 it only for post
-
00:18:33 Let's see. What happens now.
-
00:18:40 Okay, post method still works and then we try to get you see two pages in sporting HTTP
-
00:18:59 error four or five and let's see you see it is not on load method because we didn't on
-
00:19:14 love this method to accept get therefore. It has thrown an error. Okay.
-
00:19:22 So we have seen that contacts. Now. We've you already know the vivre. It is returning
-
00:19:31 with the name we want and
-
00:19:34 there is also partial with we will see that and fire. So let's try also filed return and
-
00:19:47 how we gonna do that.
-
00:19:55 Okay.
-
00:20:01 Let's see.
-
00:20:18 to file
-
00:21:03 Okay, it doesn't look easy.
-
00:21:59 So I'm just checking easy space so that is full pads.
-
00:22:16 This is my work. So.
-
00:22:27 Let's test this, okay and I action adults wild example and we will return a classic
-
00:22:42 file so to do that lets download an image from March
-
00:22:56 University and edit to our files folder
-
00:23:03 new folder files
-
00:23:10 And from here, let's download this image.
-
00:23:16 Okay. So logistic Spanish Let's name it as banished.
-
00:23:23 Into the desktop then a parent add a new file from here existing item.
-
00:23:32 Okay from desktop panel GPH.
-
00:23:37 okay, so how we can get the path of this file when we
-
00:23:46 it like this or not. It's not this way.
-
00:24:43 Okay.
-
00:24:53 Okay, one moment.
-
00:25:21 interesting
-
00:25:31 Okay.
-
00:25:40 Okay, so maybe this was work. Let's test it.
-
00:26:01 assistant
-
00:26:05 Okay, this is not the way it is.
-
00:26:33 posting internal map pads
-
00:26:46 No, this is not the way.
-
00:27:27 This is an interesting example.
-
00:27:28 Let's test this
-
00:27:29 Let me see gets hot. Let's try to get away.
-
00:29:08 Interesting. This is not working the case.
-
00:29:25 Why?
-
00:29:26 Because there is no path we can add that but there is no survey dish.
-
00:29:35 It requires to add.
-
00:29:37 A package. Let's add it and try.
-
00:29:56 So it looks like you have to install a package to access server files, I believe.
-
00:30:20 What day is this? I did it.
-
00:30:44 But still there's no map pads.
-
00:31:05 Okay, this is looks like working. So what she did is it turn file and we need full path.
-
00:31:57 So the path will be
-
00:32:02 like this
-
00:32:04 and the file name will be a banner cheap. Eh.
-
00:32:12 and
-
00:32:13 okay, so there is application file type. We need file type. Maybe they mean us first try.
-
00:32:24 think content type
-
00:32:31 Okay, so this is the content type.
-
00:32:47 You have the full path already.
-
00:32:52 Okay, wishing pads and contented. Okay, let's try and if it is working, let's see this so
-
00:32:58 this is our methods.
-
00:33:03 So here's you see when you are doing a programming. Sometimes you will be needed to or many times
-
00:33:12 solve your problems and to do that. You have to search the internet and find the correcting
-
00:33:20 that will achieve the task that you want to do and you may need to do some search for
-
00:33:31 that. Okay home final exam.
-
00:33:34 No provided has been configured to process the sublight file.
-
00:33:39 Okay, so it looks like it is working, but we have some problem.
-
00:33:51 Oh, there is the third physical file. So let's try this and I wonder if that exists it is
-
00:34:08 existing.
-
00:34:14 Okay.
-
00:34:21 Okay.
-
00:34:28 Always says that it cannot find so it appears that we have a problem with our patch.
-
00:34:48 And why Sony I'm you open.
-
00:34:53 It is here.
-
00:34:55 And it is checking whether it is here or not. So
-
00:35:01 under open this folder. What do we see?
-
00:35:09 Okay, we see the here's
-
00:35:14 in the debug folder. So this file is apparently not exist in our debug folder to make it exists.
-
00:35:24 And we do anything. Okay, there is build action and maybe we need to edit as content so it
-
00:36:01 will be holy shit.
-
00:36:02 Your control for explaining virtual pet show to get the virtual path.
-
00:36:13 Okay, I am assuming that you are holding your file in a let's say static folder there for
-
00:36:26 you have the address of it? And so I will just provide.
-
00:36:32 full pads for it
-
00:36:34 However, you could also provide a patch that will work on.
-
00:36:44 Other places on let's just copy this into our debug folder with content and copy if
-
00:36:53 never I think it should work now because it will get copied into our debug folder right
-
00:36:58 now.
-
00:37:01 And if you are publishing your project on a server than you can refer to its put folder.
-
00:37:11 Let's say you are putting it inside cww root or whatever or application root directory
-
00:37:17 wherever you are publishing.
-
00:37:21 And it will work.
-
00:37:24 However, since we are working locally we have to do another approach.
-
00:37:37 Okay home.
-
00:37:39 Or it didn't copy it here.
-
00:37:42 It didn't copy. So to make it copy here. I think we need to change this into.
-
00:37:51 Or maybe it is copied under files. Yeah here. Yeah.
-
00:37:57 It's supposed to be.
-
00:37:59 Like this. Okay now it should work.
-
00:38:04 Because all files are copied with their parts directly.
-
00:38:14 And you see in the debug now I have files folder.
-
00:38:19 Okay.
-
00:38:21 Okay. Now it is working. It is returning a file and let's see what kind of network results
-
00:38:39 you are getting.
-
00:38:41 Okay, it is returning type of document as a file.
-
00:38:47 Okay, so this is the return of this page or if it is working now, let's move to the next
-
00:38:57 one.
-
00:39:01 Which is G SOL SOL returns Json response to the client. So by the way, we have returned
-
00:39:09 the physical file and to return a real file. He needed something else. So this wasn't as
-
00:39:17 the example, but you can return also Jason or redirects. Let's make a redirect.
-
00:39:26 I don't think so. Jason will be different.
-
00:39:30 So redirect example and it is redirect. I will I will redirect to example CSS HTML.
-
00:39:38 So let's just type something here.
-
00:39:43 Okay, and
-
00:39:50 I think it should be you know it.
-
00:40:02 And it is expecting a URL. So the URL will be I think.
-
00:40:09 bulb
-
00:40:10 examples
-
00:40:11 Oh, not that way.
-
00:40:14 I think we can.
-
00:40:17 Tell examples like this.
-
00:40:31 Just look at it.
-
00:40:56 Well, we just return another view of nice. So it is just still much example easy and
-
00:41:15 the real name will be examples. Okay?
-
00:41:20 So let's try that. But this is the redirect example.
-
00:41:31 And there's also redirect permanent, which means that your browser and cage it and automatically
-
00:41:42 redirect.
-
00:41:43 Okay, so that's open or console Network?
-
00:41:49 Okay, so the readers example because we have to give full pads. Okay. Now it works so you
-
00:41:57 see now it shows what happened. However, since we didn't preserve look we have failed.
-
00:42:04 What do you know if we can see?
-
00:42:09 Okay. So what is the response?
-
00:42:14 here
-
00:42:16 Okay. This one is this one I think.
-
00:42:31 It is just a redirect.
-
00:42:34 Okay. Anyway, it is working and there is status code so returns a custom status code to the
-
00:42:44 client. So let's try status code as well.
-
00:42:51 return J status coach
-
00:43:05 and inside integer status code. Okay. Let's return 5.
-
00:43:10 Okay, so let's try the status code example with Firefox. We are able to see the better.
-
00:43:19 What happened?
-
00:43:22 So I think I will use it.
-
00:43:46 Okay, so let's open the kit white box.
-
00:43:58 Okay, inspect the time Runs Out here's that's book. And you know, it's okay now we can see
-
00:44:07 and what I'm going to do is let's first try redirect example.
-
00:44:18 okay, now it shows
-
00:44:23 Status code 200. I think I have to.
-
00:44:24 the fastest logs
-
00:44:27 Okay, does it show read on it?
-
00:44:36 And this version?
-
00:44:41 It doesn't show the redirect on here. However, it just
-
00:44:44 returns to Nev
-
00:44:48 Vso. This is not example the show. Yes, it's not redirect be box. Yeah, this is incorrect.
-
00:44:58 Just returning give so
-
00:45:00 I think I will.
-
00:45:04 return wave
-
00:45:06 examples. So this is the under whole therefore form examples here. And here's I will just
-
00:45:19 make it as root URL now it should work.
-
00:45:25 You see because the whole the examples is under home and it is under the wheels. Therefore
-
00:45:31 it should be automatically handle it. I will leave.
-
00:45:35 Okay when I refresh.
-
00:45:42 Okay, so oh, oh make samples is incorrect by.
-
00:45:56 So I like this.
-
00:46:07 This is also incorrect weaves home examples.
-
00:46:25 Chase
-
00:46:28 You like this?
-
00:46:36 So why default it is displaying the Viv.
-
00:46:43 Of index. However, examples is not displayed probably it is related to rooting. So we need
-
00:46:52 to add a route to see example CSS HTML part and
-
00:47:00 Define will perfect.
-
00:47:38 Okay, even see that so I will just leave it for now. And then we see a routine we will
-
00:48:10 do it. And so we were going to test status codes for Let's test status code.
-
00:48:18 Okay.
-
00:48:19 Let's just read on the application.
-
00:48:24 to see
-
00:48:41 the status codes
-
00:48:46 Okay, so the status code is provided I believe.
-
00:49:02 Okay, you see it. The status code is five or five is returned. Okay, and okay, let's
-
00:49:12 continue.
-
00:49:13 There are many more and you are of course free to implement your own or generate the
-
00:49:20 result yourself. Most of these methods simply generates the relevant class with properties
-
00:49:25 set accordingly for instance the content method simply generates an instance of the content
-
00:49:31 result class and fills the content property with the value you pass into the method.
-
00:49:38 Since there are many types of responses which implements the I action result interface your
-
00:49:43 actions can return any of them based in the logic of your method a common use case for
-
00:49:48 this is to return either a view or a piece of content if the requested content is found
-
00:49:53 or a 404 page not found error. If it's not found it could look like this. So the north
-
00:50:00 falls wolves be a method. I don't know if it is a generic method or not, but you can
-
00:50:06 also implement.
-
00:50:09 a method that returns a started status quote simply
-
00:50:14 In the first line, we try to load the requested product using it to be implemented get product
-
00:50:25 method If the product is found, we return it inside of a View using the view method.
-
00:50:31 If not, we return a 404 error using the not found a helper method which basically just
-
00:50:37 creates an instance of the not found result class. So in this case, there are two possible
-
00:50:43 outcomes of the action, but there could be even more if needed you are free to return
-
00:50:47 anything that implements the I action.
-
00:50:49 old interface
-
00:50:50 Okay, so I will make an example of this and you will get idea better.
-
00:50:58 Okay, so there is there will be an action named as details and simply we don't have
-
00:51:06 products in the our database right now. So what I'm going to do is if I D is equal to
-
00:51:14 32. Let's say
-
00:51:18 I will return.
-
00:51:20 That's just on the content.
-
00:51:26 Okay, I returned to do is font and else it will return not phone. So not found is them
-
00:51:35 generic method from controller base?
-
00:51:52 And this will support Port HTTP get and HTTP post. Okay, so home details and okay, so it
-
00:52:04 is expecting an ID.
-
00:52:08 And home in case he's already told me to okay, you see it is displaying ID totally to is
-
00:52:14 formed and if I make something like this, okay, it says cannot be found HTTP for all
-
00:52:20 four. Okay, so whatever we provide if it is not 32.
-
00:52:28 It will return 404 because we are returning 404 we can also return other.
-
00:52:36 Status codes it is up to us. So you can test it with debugging when I refresh it will come
-
00:52:45 into this method call and it will return not okay it is that simple.
-
00:52:52 Okay, somebody.
-
00:52:55 And action is a method on a controller usually accessible by a URL. Thanks to the routing
-
00:53:01 system. An action will usually return an action result based in the eye action result interface.
-
00:53:08 There are many helper methods available to Aid you in generating the desired results
-
00:53:13 for your action? These are the most important aspects to understand about an asp.net MVC
-
00:53:18 controller in the coming articles will dig a bit deeper into some of the more advanced
-
00:53:24 controller topics. Okay. So now
-
00:53:27 will be weaves Okay, so
-
00:53:36 Okay before going into weeks. I would like to test the image cooperating with published
-
00:53:45 by the way.
-
00:53:47 For using asp.net MVC in a remote server in for example in a Windows Server you would
-
00:53:54 need and is and inside that is it the IRS will run your application. So for example,
-
00:54:05 you can pop this shirt.
-
00:54:08 Application inside the folder and then upload it to remote server. So let's do a test here.
-
00:54:18 So it will test here with for local folders.
-
00:54:23 Okay.
-
00:54:25 And then we can make some configuration.
-
00:54:27 Or we don't need that you don't need hungry right now. So delete existing files. Okay.
-
00:54:38 So here the configuration release, by the way, if you make release it will be different.
-
00:54:44 It will be optimized Target framework and it can be framework defended. If you make
-
00:54:51 it framework defended it will not add all the libraries into the publish. So it would
-
00:54:59 reduce your size.
-
00:55:01 And Target on time.
-
00:55:04 Portable. I think we can make it with external 64 we can make producing a fight on multiple.
-
00:55:11 And even register on compilation delete all existing files and on database and okay, so
-
00:55:19 just save it this configuration may be changed according to your requirements.
-
00:55:29 What I want to test is I wonder will it published his Banner GPA into the publish folders?
-
00:55:36 I think it should but we will say so inside the test for love. We will see the published
-
00:55:44 files.
-
00:55:45 Okay, it is boiling right now.
-
00:56:02 So for example, I would have an is on my Windows server and I will just copy paste the files
-
00:56:07 here and it will start working on my remote servers and I put access it with like double
-
00:56:14 double in my server.com. Okay?
-
00:56:24 It is taking a lot of time on my computer. My computer is pretty which actually
-
00:56:34 unfortunately
-
00:56:35 So the duration it is going to take is totally dependent on your computer's specifications
-
00:56:42 feet.
-
00:56:44 Okay. Meanwhile, we can continue so.
-
00:56:49 Introduction to view this video already have an idea about them. What now? We will see
-
00:56:55 in more details in more in depth in the beginning of this tutorial. We briefly talked about
-
00:57:02 views in the MVC pattern and we even added one to our project to see what it looks like
-
00:57:07 and what it is to get you quickly up and running in this chapter. We will go more in depth
-
00:57:13 with the topic of views starting in this article where we will go over the Core Concepts of
-
00:57:18 a view.
-
00:57:21 What is a view?
-
00:57:23 Well, the controller handles the connection between the backend and the front-end the
-
00:57:29 view is the visual result of a controller action. So whenever you want to present the
-
00:57:34 user with something Visual and that's usually what you want When developing a web application.
-
00:57:39 It's placed in a view a view contains markup HTML and razor code and will often be a visual
-
00:57:46 representation of your model. In other words, the controller generates a model object and
-
00:57:51 then passes it to the view which then uses the
-
00:57:54 Model to visually represent the content of the model to the user. Okay. I think it's
-
00:58:00 published.
-
00:58:01 Okay, when I replace I see the published results. Okay, the file is also published their fourth.
-
00:58:10 It should work on a remote computer as well. You see how many DLS it has published. These
-
00:58:18 are the things that is taking time. So if we write it, let's see how much
-
00:58:26 Space it is taking.
-
00:58:31 So it is about 20 megabytes, okay?
-
00:58:40 This might all sound a bit abstract at this point, especially if you haven't seen it in
-
00:58:44 action yet in that case. I suggest you go back to the start of this tutorial where we
-
00:58:49 add a model of you in a controller to a project to see how they interact.
-
00:58:54 A view is basically just an HTML file with added support for razor code. It uses that
-
00:59:01 CSS HTML extension to indicate these extra possibilities. And as you can see in the chapter
-
00:59:07 on razor found elsewhere in this tutorial. It's very easy to combine HTML in razor code.
-
00:59:15 where our views placed
-
00:59:19 View files are usually placed in a folder called views in the root of your MVC project
-
00:59:25 to make it easier for the.net framework and your controllers to locate the proper view.
-
00:59:30 You usually create a sub folder inside of your views folder for each of your controllers
-
00:59:34 bearing the name of the controller. So if you have a home controller in a product controller,
-
00:59:40 your views folder could have subfolders with the names home and product each of these folders
-
00:59:46 would then have one or several views relating to
-
00:59:49 Actions of your controllers, it could look something like this in the solution Explorer.
-
00:59:53 Okay. So then we Analyze This you see there is controllers folder and inside that there
-
00:59:58 is home controller product controller and under views there is product. For example,
-
01:00:04 this means that DT is index and list.
-
01:00:09 Are being used for this product controller because they are under the same name that
-
01:00:17 folder.
-
01:00:19 When following these conventions you allow the dotnet framework to locate your views
-
01:00:24 automatically through a process called view Discovery will discuss that process in one
-
01:00:29 of the next articles.
-
01:00:32 A view is the visual representation of your model delivered to the end-user by your controller.
-
01:00:39 It uses HTML in combination with razor code to generate something the browser understands
-
01:00:44 in the next couple of Articles will dig deeper into some of the more advanced view topics.
-
01:00:52 Okay.
-
01:00:54 view Discovery connecting controller and view
-
01:00:59 In the beginning of this tutorial I demonstrated how a controller can return a view simply
-
01:01:10 by calling the view method this even works without parameters. So at that point you might
-
01:01:16 wonder how in the world a controller knows exactly which of your views to return for
-
01:01:20 a specific action. The answer is something called view Discovery a process where asp.net
-
01:01:26 MVC will try to guess which view to use without forcing you to specify it.
-
01:01:33 View Discovery works when you follow a certain convention when creating your project structure
-
01:01:38 we have already talked about this previously in this tutorial where we always put controllers
-
01:01:43 in a folder called controllers models in a folder called models and so on with views,
-
01:01:50 you should place them inside a subfolder named after the controller in the file name of the
-
01:01:54 view should match the name of the action. So for instance, if you have a controller
-
01:01:59 called Product controller with an action called details.
-
01:02:03 Your folder structure should look like this.
-
01:02:09 In other words the location in naming of your views should follow this convention, but just
-
01:02:18 so that is we it starts with a slash like this. So it means that it is under root and
-
01:02:27 then there is view stand the controller name like home, whatever then the action name and
-
01:02:34 see HTML so probably
-
01:02:40 Examples didn't work because we didn't specify the extension so I will make another test
-
01:02:48 in a minute.
-
01:02:54 Okay, for example CSS HTML it didn't open again.
-
01:03:09 I don't think so it is.
-
01:03:19 named defendants parts
-
01:03:24 Here it is not working. Let's continue. We will see it.
-
01:03:32 If it is you can simply call The View method from your controller actions and have the.net
-
01:03:37 framework automatically locate the proper view for you.
-
01:03:42 If the framework can't find a matching View using the convention mentioned above it will
-
01:03:51 look in one more place. So it will look real shit action name see HTML as next.
-
01:03:59 The shared folder which you may add inside your views folder is usually used for layout
-
01:04:04 files and partial views shared across multiple controllers will discuss that later on but
-
01:04:10 for now, the easiest thing is to follow the folder structure convention outlined above.
-
01:04:15 Okay? I think I Now understand our main problem because by default it is looking our home
-
01:04:24 controller and here we have to return that view, okay.
-
01:04:28 or simply what we need to do is we will have a method named as
-
01:04:37 examples and it will return weird.
-
01:04:42 We will.
-
01:04:46 Examples that's that because the examples is located under views under home controller.
-
01:04:53 So we default Behavior, which we are following the default Convention of naming. This is
-
01:05:07 how it works simply.
-
01:05:10 So now it'll work. I am hundred percent sure. I bought that.
-
01:05:16 Home examples and Tada is working. Okay.
-
01:05:20 All right, let's continue specifying a alternatively it would look we've shared action names HTML
-
01:05:29 HTML can't find a matching wave using the conversion methods mentioned above.
-
01:05:35 Let's read it. Again the shared folder which you may add inside your views folder is usually
-
01:05:42 used for layout files and partial views shared across multiple controllers will discuss that
-
01:05:48 later on but for now, the easiest thing is to follow the folder structure convention
-
01:05:53 outlined above. Yeah, we are currently using that the file structure. We are putting controllers
-
01:06:00 under controllers folder with having the first initial name like this.
-
01:06:07 Form from controller models like this and we used like leaves home and like this. Okay
-
01:06:15 specifying a weave.
-
01:06:18 If you can't or won't follow the convention, you can help the framework locating the matching
-
01:06:24 view by supplying a parameter to the view method. There are two ways. You can either
-
01:06:30 specify just a name which still requires you to follow the folder structure convention,
-
01:06:35 but supply of you with another name think of it as an alias like this. Yeah. This is
-
01:06:40 what we are doing.
-
01:06:41 Are you going to supply the entire Pat are you can supply the entire path which gives
-
01:06:47 you complete flexibility when creating your project structure? Okay, so let's try this
-
01:06:54 way as well. Okay.
-
01:06:58 So to test it, okay entire pet I actually okay. So I will add another folder like let's
-
01:07:09 say unconventional.
-
01:07:17 And inside that I will add a view.
-
01:07:20 Okay, so at new item, this will be empty and I will name it as test CSS HTML.
-
01:07:33 And to access it I will still be using home and One controller because I won't be composing
-
01:07:46 another controller for now so test it will be calm with test. We have a test method.
-
01:07:57 So the test method will return.
-
01:08:00 All Pets how like this unconventional and test CSS HTML and let's write it here test
-
01:08:12 CSS HTML. Okay. Let's try it.
-
01:08:21 Okay, then home and test you see it is working. So this is following different path.
-
01:08:44 Okay, let's continue. Yeah, we are providing the full path. So the summary
-
01:08:54 if you follow a specific convention when creating your project structure view Discovery allows
-
01:09:01 your controllers to automatically find a matching view based in the name of the controller in
-
01:09:05 the action. If you don't follow this convention, you can easily return a specific view by passing
-
01:09:11 its path and or name to the view method.
-
01:09:15 Okay, so nice.
-
01:09:19 Okay.
-
01:09:21 passing data interviews
-
01:09:23 Ave you can exist without a model or any other data from the back end, but in most cases
-
01:09:32 you need to somehow Access Data made available by a controller in your view since your view
-
01:09:37 shouldn't have to know about your controller as per the rule of separation of concerns.
-
01:09:42 Your controller is responsible for making the data available to the view. There are
-
01:09:47 two main ways of doing this either you define a strongly type model and then pass it to
-
01:09:52 the view. Are you can use the view data viewbag containers to make data available.
-
01:09:56 Ball to the view. Let's discuss these approaches now.
-
01:10:03 Please notice that there will be a bit of overlap in the information provided by this
-
01:10:07 article in the QuickStart article on adding a model to your project.
-
01:10:11 Okay, so using a view model.
-
01:10:17 Since this technology is called MVC short for model view controller. The use of a view
-
01:10:23 model is definitely the cleanest and most common approach for passing data into a view.
-
01:10:29 We'll talk more about the model later in this tutorial, but for now just know that it's
-
01:10:33 basically just an object usually representing something from The Real World. You'll also
-
01:10:39 run into the concept of a view model again will dig deeper into this later on but to
-
01:10:44 describe it shortly a view model is just a model.
-
01:10:47 Passed to a view so it can be something that already exists in your project like a user
-
01:10:52 or product object or class you specifically Define to represent the data you wish to access
-
01:10:58 from your view.
-
01:11:00 A model doesn't have to be a complex class though. It could in theory be something as
-
01:11:06 simple as a string and integer or a date-time in other words anything found in the.net framework
-
01:11:13 can be used as a model but in practice your model will usually be a class consisting of
-
01:11:18 at least a couple of properties. So for instance a model used to represent a product could
-
01:11:24 look like this. Okay. So to continue in this tutorial, I will add
-
01:11:30 New but model, so do they give yeah, let's add a product model on the models. So it will
-
01:11:40 be basically a class and it will be less name it as product.
-
01:11:46 Okay, and it's a utilities public class product. So there's places we can access it.
-
01:11:57 And basically it's just copy and paste it.
-
01:12:02 And I will add another page to my controllers. Let's say that controller as product empty
-
01:12:14 controllers.
-
01:12:16 I will name it as product controls.
-
01:12:18 You see be at the controller board to the end of the name of the page product controller.
-
01:12:29 And inside product controller, I will add an eye action result. It is already there,
-
01:12:34 but I it will be like this. Okay, so it it will use the product from product model. So
-
01:12:42 to be able to use it. I will add using lecture one models here. So it will be all the models
-
01:12:50 inside. The models folder will be available like moving or product.
-
01:12:55 So it will generate a product and it will return VAR width product. However, since we
-
01:13:02 don't provide the we've named it will look for in this view inside views to do that.
-
01:13:10 I will add a new folder named as product and inside this product. I will add index HTML
-
01:13:18 because it is what it will look as default.
-
01:13:23 Okay. Now let's write as
-
01:13:34 Let's run and see whether it is working so far or not.
-
01:13:47 Okay, so by default it is opening the home and the index. So therefore we will be needed
-
01:14:03 to product.
-
01:14:07 and
-
01:14:11 Index or just product?
-
01:14:15 Okay, let's see. What's may be the problem.
-
01:14:20 Okay, we have product product controller inside for the controller we have or we have details.
-
01:14:30 So therefore I have to Define details like this and here's it will tell me that details.
-
01:14:38 Okay, I see so I will change the name of this detail or let's provide the Vivo to name as
-
01:14:47 well.
-
01:14:48 Luckiest index. Okay, since the action name is not matching the VM name. I have to provide
-
01:14:58 the VM name as well. Okay, so I will take a note here as well.
-
01:15:19 The action action name is details.
-
01:15:24 You may miss index.
-
01:15:29 Okay done product.
-
01:15:34 then details
-
01:15:36 then I can provide ID.
-
01:15:40 Okay. So inside the V we will use the model which is product. So let's continue. We haven't
-
01:15:52 edited yet notice how I pass the product instance to The View when I call the view method inside
-
01:16:00 the product details view. I can now Define the product class is the model this view can
-
01:16:05 and should expect using the ad model directive located at the top of your view file. Okay.
-
01:16:11 Go to RV file, which is here. This is under the waves product index.html and at the top
-
01:16:19 we will add model as equal to lectures. Okay, this still seeing lecture 1 because we have
-
01:16:29 just copy-pasted models that product Now by default. It will expect model as a model from
-
01:16:41 models on the product. I mean the product on the models it is here.
-
01:16:48 With that in place, you can now start using your view model and its properties in your
-
01:16:54 view. We can start using that such as let's be are.
-
01:16:59 Okay, H model Titan I model price when we by the way, can I make this default opening
-
01:17:08 page?
-
01:17:09 right click
-
01:17:10 Maybe from the properties.
-
01:17:14 Okay, there's startup object. No.
-
01:17:22 Let's look for it.
-
01:17:29 Okay.
-
01:17:30 Okay, there's the web top it says but I don't see it here.
-
01:17:57 Is properties but no website. I mean the web top.
-
01:18:13 project properties
-
01:18:17 Okay, there is Roach.
-
01:18:24 home
-
01:18:26 Okay, so probably we have to set the default from yes.
-
01:18:37 in the road complete or start writing which is here and
-
01:18:42 Yeah, it will by default settings here. So and points at it was showing example how
-
01:19:10 So default vote is controlled at home action index and I have to change it how let's see.
-
01:19:20 There is map it takes a turn. You're not this one. I think.
-
01:19:31 What does this?
-
01:19:33 map controller
-
01:19:35 So this maybe it's meant controlling Road and here's sitting name String pattern.
-
01:20:03 And points construction methods voting as specified road with the given name pattern
-
01:20:11 and default. So name name is the name of the route name of the road is product or new frame.
-
01:20:17 What time do you love the pattern Roots? I think it is details.
-
01:20:25 Object defaults, let's say turn the to go see his mother. Okay. So let's check our product
-
01:20:34 and control the product controller. So it takes an ID as ID. So let's provide ID to
-
01:20:45 And here ID is equal to ID.
-
01:20:50 Okay product doesn't okay. So here I have to set idea as well.
-
01:20:59 Public in idea now it should work and here I can set it.
-
01:21:08 Yeah, if I don't provide ID, I don't know what happens. Let's see. So now when I run
-
01:21:15 it it should.
-
01:21:18 Open the product controller by default with the details action.
-
01:21:24 But I'm not sure it will do it or not.
-
01:21:31 Okay, so it didn't work.
-
01:21:33 Or so this is maybe the side text.
-
01:21:48 No, not that one.
-
01:21:59 That's taking off my pH.
-
01:22:13 Okay.
-
01:22:16 Okay. So this is the way it is. So we were doing incorrectly and points map control name
-
01:22:24 default pattern control. Okay here product action is details.
-
01:22:32 And there is ID I think.
-
01:22:37 Can we set a default under such as 32? Yes. Try it.
-
01:22:45 Yes nice. It
-
01:23:00 is working that see if the ID is set as default or not from here.
-
01:23:09 So here I will put a br and beige already equal to.
-
01:23:17 Model that I D.
-
01:23:23 Why it doesn't show the ID probably.
-
01:23:31 Okay, let's see product controller or Eddie.
-
01:23:40 oblique inch ID
-
01:23:44 Yeah, now it's you know, it's he's probably it was related to intellisense cage its Visual
-
01:23:57 Studio.
-
01:23:58 Okay, now we can see if our default route is working or not.
-
01:24:08 Yeah, I can also provide different ID. But can I provide like this? I wonder
-
01:24:19 No to provide a different idea. I need to provide it something like
-
01:24:23 this problem is no it's still not working.
-
01:24:35 interesting
-
01:24:36 so
-
01:24:42 maybe here I have decided like this.
-
01:24:45 I wonder I wonder if this would work.
-
01:24:58 so this is the pattern but
-
01:25:07 the pattern throwing error Okay, so
-
01:25:10 Yeah, probably what we need to do is we have to set the default value inside of ID. So
-
01:25:32 how can we do that? We can do that as I think.
-
01:25:40 like this if it is equal to null but integer cannot be know what
-
01:25:52 so 0
-
01:25:55 We'll set it to 32 else.
-
01:26:03 We will said it already. Yeah.
-
01:26:15 You know, it should work.
-
01:26:20 this restaurant
-
01:26:21 Okay, so what happens?
-
01:26:22 We haven't ever.
-
01:26:25 All our Port is in years.
-
01:26:31 Stop application. Okay, let's change the port of our application. I think it was somebody
-
01:26:44 here.
-
01:26:47 Okay. Yeah here the port let's make it.
-
01:26:55 Something like this.
-
01:27:02 We didn't save it for a Lobby. That's right, right.
-
01:27:06 I have saved and restarted.
-
01:27:08 Is expressed as a problem?
-
01:27:11 Okay, it says it is being used by the Chrome.
-
01:27:24 Let's try something like this.
-
01:27:33 restaurant
-
01:27:35 You know, it's working UCD Port of the Local Host has changed.
-
01:28:07 Okay ID has arrived by default. Can we set now? Some different IDs now it is working.
-
01:28:16 Okay. Okay. Let's continue. Okay.
-
01:28:18 Thanks to the fact that you specify a strong type as the model of the view. You will get
-
01:28:29 help accessing members of the object through intellisense and your code will be validated
-
01:28:34 during the build process to make sure that you only use properties methods found on the
-
01:28:38 model object. Okay, then there is dynamic leaves.
-
01:28:45 If you don't declare a model type for your View using the ad model directive The View
-
01:28:50 will not expect any model of a specific type to be passed into it. But that doesn't prevent
-
01:28:54 you from actually doing just that and even using the object. This is often referred to
-
01:28:59 as a dynamic View and is not used very often because you lose out on the benefits of intellisense
-
01:29:05 support and compile time check of the properties. Okay. So this is also possible. However, it
-
01:29:10 is not suggested.
-
01:29:15 Let's make an example of this.
-
01:29:18 Okay, so I will show you an example of this case, but it is not suggested.
-
01:29:29 Let's add a video here and let's call the action name as dynamic.
-
01:29:37 so it will come here with Dynamic and
-
01:29:41 I will add another model. It is just a class actually nothing else regular class that we
-
01:29:48 know from C sharp.
-
01:29:53 And this name is dynamic.
-
01:29:55 Okay inside this Dynamic view of I will add name and it will be n integers and let's set
-
01:30:07 the default value for each something like this.
-
01:30:12 Okay.
-
01:30:13 By the way, it is not a good name. So I will have it as a rank. So inside this Dynamic
-
01:30:21 CSS HTML.
-
01:30:23 I will print it with model dot rank. Okay? Okay. Now we should be printed. It will not
-
01:30:34 expect a model that has a rank parameters. Okay.
-
01:30:38 And I can only think.
-
01:30:43 I can even turn it into a I can even format it. But yeah, that's just format it.
-
01:30:54 So let me show you a chance.
-
01:31:00 and the wrong I will
-
01:31:03 tell the parameters so
-
01:31:14 equal to more that's Funk, too.
-
01:31:20 Yeah, I think I have to Define it at east.
-
01:31:32 wrong, too
-
01:31:41 Her make it like this.
-
01:31:46 Yeah, no I can use to string.
-
01:31:51 Okay, then like this.
-
01:31:56 Or perhaps I have to use it as like this.
-
01:32:01 Yeah now working and simply here. Okay. Now let's run the application.
-
01:32:16 Okay, no product and dynamic. Okay, it is not working cause
-
01:32:38 we didn't return the dynamic wave inside our method.
-
01:32:45 which is his
-
01:32:47 oh, by the way, this is Dynamics here. So
-
01:32:54 okay Dynamic model. Yeah here I have to return it.
-
01:33:01 We didn't ride it.
-
01:33:04 So public I action results Dynamic it will return.
-
01:33:11 We by the way, I have to first Define a dynamic model.
-
01:33:16 My mother equal to 9 mph and return view the view name will be dynamic.
-
01:33:28 Or whatever the name I once I have given Dynamic, but let's change it. So it won't it won't
-
01:33:32 be test Dynamic confusing.
-
01:33:45 And the model object which will be here. So it will be dynamic therefore. It won't have
-
01:33:57 a check at runtime or compile time.
-
01:34:01 I'm in not a compile time. It will check by around time current. It won't solve any error
-
01:34:07 because we have used the correct name.
-
01:34:11 And let's try product.
-
01:34:15 Okay dynamic.
-
01:34:18 Okay, now it's working but not working as we wanted.
-
01:34:28 Yeah, I have to write it like this. Okay, because it was just seeing that as a text.
-
01:34:42 Now. I am telling that it's the variable and object that will be printed.
-
01:34:47 Yes, it
-
01:35:00 is working. However, this is dangerous. Why now? Let me show you why I would let something
-
01:35:07 like this and let's say I have written like this. So what will happen?
-
01:35:12 Because the variables are case sensitive in c-sharp. We will get an error at the wrong
-
01:35:21 time and you won't get a error rate of compile time because this is using Dynamic model.
-
01:35:30 So when the application is running it will look for a variable name it as wrong with
-
01:35:39 first letter is being bigger. And since there is no such variable. It will throw a runtime
-
01:35:48 error.
-
01:35:49 Okay, you're so you see it says that.
-
01:35:56 Lecture 1 models Dynamic does not contain a definition for long. So you see runtime
-
01:36:01 binder exception. We are getting
-
01:36:02 Okay, let's add some comments here.
-
01:36:33 Okay, okay.
-
01:36:44 Now you get the idea that is why you should not use Dynamic weeks.
-
01:36:57 So you could take the example above and remove the ad model directive in the top of the view
-
01:37:02 and it would still work in this situation. The model property would be considered a dynamic
-
01:37:08 object where you can access properties without the compiler checking for their existence.
-
01:37:13 Of course that also means that if you try to access a non existing property page generation
-
01:37:18 will fail during run time resulting in a nasty exception there for dynamic views are not
-
01:37:25 used a lot. Okay. I just shown you
-
01:37:28 At so using view data via back. We have seen that already. But let's see it again as an
-
01:37:34 alternative to the strongly typed approach to passing data to a view you can use the
-
01:37:39 so-called view data view bag containers. You can add stuff to them from the controller
-
01:37:44 and then automatically be able to access the stored data in your views. It's actually quite
-
01:37:50 easy and you can accomplish almost the same things as if you had used a strongly typed
-
01:37:55 model.
-
01:37:56 Here's an example. So it is so simple under my product controller. I will just add an
-
01:38:03 another action and it will be details with data and when I run it.
-
01:38:11 By the way, I was just make a simple modification.
-
01:38:21 Let's say
-
01:38:22 newspaper or the quest like this and give back dots
-
01:38:33 this time
-
01:38:38 let's say ID equal to
-
01:38:45 Like this however, now there is a problem or application is expecting a mother.
-
01:38:53 And therefore we need to have another weave.
-
01:38:59 to display this
-
01:39:01 writing change
-
01:39:10 here we have to make some changes such as such as
-
01:39:15 I have calls.
-
01:39:19 Okay, so we will modify this code and whether is the model is provided or V, which is used
-
01:39:32 we will be able to do that. And how we're going to do it is I think we can make it like
-
01:39:43 this.
-
01:39:45 Okay.
-
01:39:48 equal to
-
01:39:49 okay, if it is, no, then we're back dot title else this.
-
01:40:12 Yeah, it should work.
-
01:40:17 Since this is sitting this should work.
-
01:40:21 But I think we need to.
-
01:40:25 Put complete no check here and price.
-
01:40:35 By the way for price.
-
01:40:40 Price is double Darfur.
-
01:40:44 We need to check as zero or not. What we get is 0 that we can't be sure.
-
01:40:53 so
-
01:40:54 Let's let's do this check like this if model equal to null.
-
01:41:03 Yeah wedding measurement like this.
-
01:41:07 Okay, then the price.
-
01:41:11 or price and
-
01:41:15 this is dynamic heater for hiding a double.
-
01:41:24 It is a 6 inch models. There is ID.
-
01:41:30 and ID is integer there for
-
01:41:34 your ID
-
01:41:38 Okay, I think we can make it like this.
-
01:41:43 And in our product controllers, yeah, it will be like this.
-
01:41:54 You can Mike like it and by default we can assign something like this. Yeah.
-
01:42:09 Okay.
-
01:42:12 Here we will use title rice. I think I can write the price as to switching with formats
-
01:42:25 and ID.
-
01:42:27 Okay. Now let's check it out.
-
01:42:31 Though I am not sure about various we can check model is known or not. So we will see.
-
01:42:51 Okay. Okay model is existing right now because it is the default then our live action method
-
01:43:08 name is details view data.
-
01:43:11 It is the important fact.
-
01:43:15 Busy later or we have a problem. Why?
-
01:43:25 Product has the details view data. Oh because of this because I have to return the view
-
01:43:33 name since they are not same.
-
01:43:37 Okay, and you bake was just
-
01:43:49 You later.
-
01:43:50 Let's remember that as well.
-
01:43:58 Okay, so the mud monkey then.
-
01:44:32 Okay, I think we're back is the better one. Anyway, let's run our
-
01:44:50 control methods
-
01:44:52 Florida
-
01:44:53 Fucking we have an error. Okay cannot perform runtime binding on a new reference. He is.
-
01:45:05 Which is so on our page.
-
01:45:11 Okay, it is returning index HTML.
-
01:45:21 of product
-
01:45:24 or it has returned incorrect one year we have to return this one because we have modified
-
01:45:28 this one.
-
01:45:39 You could also use we're back live data. However, I think is better more better approach.
-
01:45:52 Continue and finally should work. Okay. So model ya know so we can do no check. Yes.
-
01:46:08 Yes.
-
01:46:09 Well, we have enough because coma.
-
01:46:15 Cries price. What is the problem?
-
01:46:24 We didn't assign.
-
01:46:34 All we have used different names that are for I have to use same name such as this one
-
01:46:42 or I could change the names here, but I think I will make them same day.
-
01:46:50 the title
-
01:46:52 price and idea no should work.
-
01:46:56 We can remove this we don't need to pay any more.
-
01:47:10 Okay.
-
01:47:13 Okay product.
-
01:47:19 Yeah, it is working with default ID and then we can provide ID like this and it's working
-
01:47:30 as well. Okay. Nice. So now you get the idea you can use model or if model is known you
-
01:47:37 can use Vivek. It is totally up to you how you design your application?
-
01:47:42 Okay, let's read it. The major difference here is that there's no compile time checking
-
01:47:51 of these properties and no help from the intellisense when writing them. In other words, you could
-
01:47:57 easily Miss spell a property name and you wouldn't notice until you tried using the
-
01:48:01 view. Therefore. You should only use the view data view bag for very small amounts of data.
-
01:48:07 However, you should remember that. You are free to combine the usage of view data view
-
01:48:12 bag with a traditional
-
01:48:13 Wrongly type view. Okay. So what is the difference between big data and Vivek? You will have
-
01:48:20 noticed that I have used two terms for dealing with Dynamic view data the view data and view
-
01:48:26 bag properties these actually both refer to the same thing, which is a dictionary of keys
-
01:48:31 and values the objects. However, the view bag is a dynamic object representation of
-
01:48:38 the dictionary allowing you to access the data as if it were properties of the viewbag
-
01:48:43 object instead.
-
01:48:44 Of entries in a dictionary you are free to use both properties interchangeably, since
-
01:48:49 they always refer to the same data. So for comparison, here's an example of how it would
-
01:48:53 look if you used both approaches. Okay? No, we understand it.
-
01:49:01 okay notice how I use the view data and therefore a dictionary based approach for reading and
-
01:49:08 writing the product title while I use the object based dot notation to access the product
-
01:49:13 price that leaves you with a few smaller difference EG the ability to check for the presence of
-
01:49:19 a given key value in the view data collection using the contains key method at the end of
-
01:49:25 the day, you should use the approach that you find most appealing and then stick with
-
01:49:29 it for consistency Okay, so
-
01:49:32 Also try something else here such as I wonder if that would work.
-
01:49:38 Okay we back and we'll check having let's say
-
01:49:44 Okay other name? Okay. Let's run this beat no data first.
-
01:49:54 And we took data as well again.
-
01:50:03 Currently view base doesn't have a object as this one.
-
01:50:16 Oh, it didn't work.
-
01:50:23 Why why it didn't work?
-
01:50:31 I think we have put a question mark or a place like it should have been like to hear now.
-
01:50:37 Let's try like this.
-
01:50:51 Okay, so you see vbh have Advantage why because we are able to do a tri check with these various
-
01:51:03 much easily. However with live data we have to check that whether it contains that key
-
01:51:09 or not and which increases our code amount that we have to write but we have you can
-
01:51:16 check we're back.
-
01:51:19 Feels like this easily. Okay, so this is an advantage.
-
01:51:25 Okay, and next is partial leaves, okay.
-
01:51:32 So what is partial weaves partial views?
-
01:51:41 So far we have only worked with complete views everything returned to the client exist in
-
01:51:46 this view. However, there are many ways of splitting up the mark up into several places,
-
01:51:51 which is a good thing for several reasons the most obvious being to reuse view markup
-
01:51:56 and or logic in multiple places. Okay, I think I will leave the partial views the next week.
-
01:52:05 So we will also remember we have again.
-
01:52:08 and it would like
-
01:52:11 rehearsing
-
01:52:13 Okay, I think we can leave it to next week. How much time here we are almost at two hours.
-
01:52:29 So let's not take note of what we have seen so far this week lecture 3 context.
-
01:52:46 Okay.
-
01:52:49 So let's check the code. We have written so far.
-
01:52:53 Okay. First of all, we have seen how to define controllers change how to define custom controller
-
01:53:06 and change the default controller.
-
01:53:11 Okay soft.
-
01:53:13 You home to write a custom rod pads for both controller in and he SP.
-
01:53:33 But that score and we see application.
-
01:53:44 Okay. Yeah, we have seen that. What does he have seen?
-
01:54:04 Okay, so
-
01:54:09 Okay.
-
01:54:11 Let's open our code.
-
01:54:21 how to
-
01:54:23 single controllers
-
01:54:26 I'm so cold.
-
01:54:29 Okay.
-
01:54:30 how to return
-
01:54:34 Boil or different HTTP status codes or yeah.
-
01:54:43 Jehovah to do a redirect from him action calls.
-
01:54:50 how to us
-
01:54:53 Objects to the waves flow controller speed model for Big Data or you back approaches?
-
01:55:11 Move check to parse all those a beta waves.
-
01:55:28 Okay.
-
01:55:31 Okay home to use how to use Dynamic models in waves.
-
01:55:41 Okay.
-
01:55:43 I think I will change this.
-
01:55:46 as like this
-
01:55:47 so it's going to be more.
-
01:56:09 Experian ATIV
-
01:56:10 Okay.
-
01:56:11 What is the default compilers at taking of his we got night?
-
01:56:18 core and we see
-
01:56:19 Okay, honey. Oh to do.
-
01:56:35 almost
-
01:56:36 it HTML is assigned text in waves.
-
01:56:51 form positive
-
01:56:54 Okay. So this is how we post his drought HTML and this is how we post it razor sign text.
-
01:57:06 okay, and then
-
01:57:12 what else what else what else?
-
01:57:17 Okay guys really expanding our project adding more features.
-
01:57:26 then let's
-
01:57:29 check it out. Okay last.
-
01:57:37 Okay.
-
01:57:39 We will see the partial release next week. So
-
01:57:46 let's go to previews and
-
01:57:52 pasting data in two weeks
-
01:58:04 or kid. I never use you very much.
-
01:58:06 the discovery specifying way
-
01:58:14 What is this?
-
01:58:18 Action results. Yeah
-
01:58:38 actions
-
01:58:47 Okay. Okay. I think it's good we have
-
01:59:08 Covered everything we have seen.
-
01:59:13 action verbs
-
01:59:15 more ice off. Let me upload our code to our GitHub repository.
-
01:59:54 Since we have added some libraries to have project. I think it is taking a little bit
-
02:00:04 more to add everything.
-
02:00:10 Let's see how many megabytes it is.
-
02:00:17 You're all wow is so big guy.
-
02:00:22 This is really really bitch.
-
02:00:28 What's taking this much?
-
02:00:32 I spy a small those properties perhaps why need it?
-
02:00:42 Wow, binary saw beak why?
-
02:00:47 It is probably due to a framework we have edits.
-
02:00:54 It is huge actually.
-
02:00:57 Each one of these is taking huge space.
-
02:01:07 Here's where is release version?
-
02:01:13 Okay. Yeah, I just had as its let's push it. I hope it'll push it.
-
02:01:35 which
-
02:01:38 without any
-
02:01:43 by the way, you don't have to push debug folder to your code management because you can regenerate
-
02:01:51 it with recompile unless you have put in your debug folder items manually. So that is not
-
02:02:00 a necessary that sensitive. Let's see anything else here.
-
02:02:09 Let's open our GitHub repository to show you something. I have already told you that you
-
02:02:18 can join our Discord Channel and ask many questions. So please do so if you have any
-
02:02:26 questions any suggestions related to our course, please
-
02:02:48 He is do so by day that invite link was videos interesting role. It is not of our students
-
02:02:56 who make asked picture and name.
-
02:03:00 Okay, probably one of the this court at means that I did set here. Probably a giant star.
-
02:03:10 his profile is
-
02:03:12 I would say funny. Yeah, okay after we have come into our disco Channel, you can write
-
02:03:22 our general text you can mention me like this and you can also take the lecture role from
-
02:03:33 Here when you click it, for example, MVC is here if you click it.
-
02:03:43 Is he like this and it will come here? Okay.
-
02:03:46 I will need to shower for providing confusion. Okay, so currently it is uploading pushing.
-
02:04:00 or
-
02:04:04 let's see if it uploaded.
-
02:04:06 It has failed, but I want repeated where to.
-
02:04:17 Okay hard piece of Pilots. Let's fix this error as well. Probably we need to increase
-
02:04:28 some cage size.
-
02:04:29 Okay, let's find some answers.
-
02:04:43 Okay.
-
02:04:48 Yeah, he is. So this is a comment that we should run. I think this won't fix if that
-
02:05:08 ever happens again.
-
02:05:10 Okay, it has failed again, I believe.
-
02:05:14 You must reach right?
-
02:05:26 So we have increased our post buffers.
-
02:05:31 Okay, it says everything is pushed by the way the first it compressed objects then pushes
-
02:05:51 to eat her.
-
02:05:54 And probably only get up it is getting extracted decompressed.
-
02:06:06 We are waiting.
-
02:06:12 results from guitar
-
02:06:19 It's hung up. By the way. This part is not important any worse anymore. So this was the
-
02:06:29 end of the lecture or we are still uploading data as you can see.
-
02:06:36 Okay. So if you have any questions, please let me know from our discussion or you can
-
02:06:43 also email me.
-
02:06:46 And end of lecture, hopefully see you next week.
