We will be undergoing scheduled maintenance on May 20th, 2013 at 02:00 GMT.
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Welcome to the HTML Encoding Example video. Now in this video I'm going to do an example, a real quick demo of what we talked about in the video entitled HTML Encoding. So you may want to go take a look at that video before you watch this one if you haven't already done so. Now very simple set up here, I've opened Visual Web Developer 2010 Express. I'm going to create a new website, Visual C Sharp, I'll take ASP.NET website, I'll take the Default Name. Mines website 19, I'll click that, let it gyrate and start it up. Now what I'm going to do here is demonstrate the differences between the standard old ASP Inline code trick and this new HTML Encoder. Now it opens me up in the Default ASPX file and I'm not going to work in that one. I am going to work in the Site Master File because it's a little easier for purposes here. So what I want to do is, I want to show you some encoding taking place and so what I will do here, is I'm going to come down here and add a couple of div Tags. Now notice I did like a Snippet. I'm going to do it 1 more time here and notice I'm just going to start div and as soon as it's there Tab twice and notice it puts my div in and so here's the two div Tags that I have. And now what I'm going to do is, I want to go to the Code Behind Page on Site Master. Well there's one easy way to get there, just come out here to Site Master, double-click on CS and that takes me right there. Now what I'm going to do is, I'm going to put a function out here to run and return some, just some string information to us to show you how it's going to be encoded. Alright. And so I'm going to do a Protected Static String, hello world, just like that and then I'm going to just, when you call this, just return hello world from function hello world. Right. Sounds confusing but now here's what I'm going to include here. I'm going to include some right braces and as you know, these could be problematic. If this is coming back into my program from somewhere, this needs to be handled and not passed in as these right brackets because it could be a cross-site scripting attack, someone could be injecting something that I, that could be something other than innocent code so I want to encode these things and make sure they don't get handled that way okay? And so that's what's going to handle Hello World Function and so what I'm going to do now is go back out into my Site Master and notice I'm just in the Source Code here, I'm in the HTML in the first div Tag up here, I am going to use the old standard ASP.NET processing code and I'm going to call hello world and I will call it just like that. And then in the second div Tag I'm going to use the new HTML Encoding and notice it has the colon, not the equal sign and I'm just going to call hello world again. So I'm going to call it twice. We're going to see the very same thing happen, then I'm going to come back and show you what it did. Alright. So now let's go up here, run it, see if I fat fingered anything that prevents it from kicking off without a problem. And it's going to run and you'll notice down here at the bottom we see both the instances of our function running and there doesn't seem to be any difference. Well if we go up here, come to the Web Developer, I'm in Firefox, all we want to get to is the Page Source and if I get the Page Source, let me make this large so we can see it and scroll down, you will notice the first one that I did, the old standard, actually passed those in just the way they were. The encoding choice actually encoded these and turned the right bracket into the at GT semicolon side. So this tells the browser exactly how to render these things but it doesn't pass them in as this and so this can help protect us from cross-site scripting or other injection type issues. So anyway that's a real quick, real simple example of how this new HTML Encoding Shortcut Tool will help you out.
| Course: | Designing and Developing ASP.NET 4 Web Apps (Exam 70-519) |
| Author: | Mark Long |
| SKU: | 34292 |
| ISBN: | 978-1-61866-029-9 |
| Release Date: | 2011-12-31 |
| Duration: | 8.5 hrs / 108 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |