Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Programmers have been creating web applications with Visual Studio for years. When Visual Studio first debuted in 2002, it included a new way of building web sites with .NET-managed libraries. For those of us who were building ASP classic sites, this was a welcome change. Now ten years later, we continue to see phenomenal growth in web tools from Microsoft and other vendors. In this movie, I will show you how to create some ASP.NET web sites. Just so you know, however, this is a big topic--much bigger than we can cover in a single movie.
But you can find other ASP.NET titles here on lynda.com. I am inside Visual Studio, and I am going to create a new ASP.NET web site. To do that, I go to the File menu, and choose New > Web Site. The default location for this application will be in My Documents folder, inside the Visual Studio web sites folder. It may be a different location on your computer. I want to make sure this is a C# application, and then I will choose ASP.NET Web Site. Now, creating this kind of web site project in Visual Studio gives you a very simple folder-based site.
I can even select my browser by choosing Browse With, and then it will show all the registered browsers. Now you may notice that in the lower right-hand corner of my screen, a dialog is popped up down here that says ASP.NET Development Server. This means that I don't have to have a production-quality web server on my developer machine. I have this dedicated light-weight developer-only Development Server available. It's picked a local host and a port on my machine for this web site. I am going to browse with Firefox and then click Browse.
Choose No to this dialog. There is my sample page. Notice I have got a couple of links across the top here. I can go to the About page or back to the Homepage. And again, it's loaded it with the correct port number up here in the browser. There are several other types of web applications you can build. We can find more here in the File menu, under New > Project. Remember last time I chose Web Site? This time I am going to choose Project and then click Web.
Over here, you can see an ASP.NET Web Application. This is a more developer- centric model of the web application. It's going to compile some DLLs. It's a little more sophisticated than the one I just showed you. There is also a number of other types of ASP projects here. Model View Controller is one of the very popular new ones. It's called ASP.NET Model View Controller 2 Web Application. I encourage you to look at some of these other types down here. I am going to look at just this one here: ASP.NET Web Application.
This time it's going to look out on my hard drive, to my Exercise File folder. Again, on your machine, you can choose wherever you like to put these files. I am going to go ahead and click OK. It doesn't look much different. It's just what happens when you compile the application. And now in order to add an item to this project, you can no longer just add it to the folder on your hard drive. You will have to go to your Web Application, right-click, and choose Add > New Item, so that Visual Studio knows about it.
I thought I would edit a little bit of code. I am going to click on the Designer, and then I am going to go to this section right here after this text and hit Enter, which adds a new paragraph, and then I can add controls by dragging and dropping. I can also edit this in my HTML, if I'd like. I am going to add a button, and then I am going to add a hyperlink. Now, this hyperlink is editable by going to the Properties window. For instance, I can change the text to say something like "Go to About page", and then for the location of where to navigate to, I can click on this property, and choose from this dropdown, and pick any of the pages that are in my web site.
So I am going to tell it to go to the About.aspx page. Again, I can browse by choosing right-click > Browse With. This time I will just view in browser, which I believe on this machine will launch Internet Explorer. Now, I'll click on the hyperlink, and it moves me to the About page. I can also put code, and I can debug ASP.NET applications. Let me show you how to do that.
I am going to close this browser. I am going to go move to this button, and I am going to double-click on it which will stub in some C# code for me. Double-click on the button. It switches me over to the C# view of the code behind page, and inside this procedure here, I am going to modify the text on that hyperlink. The hyperlink control is called Hyperlink1, and I am going to change the text to say "lynda.com", and then I want to change the navigate location.
That's called NavigateUrl. And I think I am ready. Since I want to debug the application, I no longer need to go over here and right-click and say View in Browser. I need to go up here to Debug and say Start Debugging. That will attach the debugger to the browser. So let me do that.
I will choose Debug > Start with Debugging. Save my changes. I have the Development Server launched. When I click on the button, it changes to text, and now when I click on the hyperlink, we no longer go to the About page, but we go to the lynda.com web site. I told you I could debug this, so let me switch over to Visual Studio, and I am going to put a breakpoint here by clicking on this margin. If you don't have the margin, you can press F9.
Now, there is a breakpoint there. I will switch back to my browser, click on the button, and notice what happens. I switch over to Visual Studio, and there is now yellow marker on the line of code where I had the breakpoint. Now, I can step through my code, I can hover over these values to see what's currently stored in there, I can edit the values, I can rewind my code, and re-run that line of code again by dragging the yellow arrow up to the previous line.
So as you can see, there are lot of ways of working with web sites in Visual Studio. The key point today is that Visual Studio provides all the tools you need to edit, build, debug, and deploy those web sites.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 102980 Viewers
61 Video lessons · 89661 Viewers
71 Video lessons · 73306 Viewers
56 Video lessons · 104886 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.