ASP.NET: websites vs web applications

Web application. I'd never actually considered using the website option, but from looking at the links below it seems much more limiting as we need to access custom classes and business logic etc within the website.

http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5
http://webproject.scottgu.com/Default.aspx
http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx


However, I'm currently building a site using ASP.NET MVC instead which is in one word, brilliant.
 
Not meaning to steal this thread but...
just looked on the mvc website and checked the video out. First thing that struck me was the fact that the pages looked like the asp classic style of code and html pushed together, which in normal asp.net you try to avoid. Is this the case, or just a bad example video?
 
Web application. I'd never actually considered using the website option, but from looking at the links below it seems much more limiting as we need to access custom classes and business logic etc within the website.

http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5
http://webproject.scottgu.com/Default.aspx
http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx


However, I'm currently building a site using ASP.NET MVC instead which is in one word, brilliant.


Can you give me a little review of MVC? I can see the appeal, but I was going to wait till it was a bit more mature before I went head first in.
 

I know what you're saying, but the MVC framework separates your model (database access etc), controller (given a particular URL what page do I display or what action do I perform) and the view (the look of a particular page) very well.

If you mean things like Html.Actionlink then that's a function provided by MVC to generate a href links for you, you don't have to use it.

Consider you have this link to access a page on your system:
http://127.0.0.1/blog/archive/july

You could type:
<a href="/blog/archive/july">July</a>

But what if you changed your site so that the blog archive URL is now:
http://127.0.0.1/archive/blog/july

You would have to go back and update all the links manually. But using ActionLink the framework does it all for you. So the a href can be generated using:
<%=Html.ActionLink<ArchiveController> ( a => a.blog("July"), "July Archive") %>
and as long as your ArchiveController class has a blog() function you'll be good to go :).

You might also see them using ASP to access the ViewData array; using your controller/model you can save values into this and access it within your page, i.e. in your controller you may have a new_post function for your blog which is called when someone accesses /blog/new. You want to give this page the "New Blog Post" title, in which you set in your controller in the new_post() function:
ViewData["title"] = "New Blog Post"

Then in your view pages it just references it by having:
<h1><%=ViewData["title"]%></h1>

There's also things for building forms, where to place form validation errors etc etc which although they all appear as ASP tags are perfectly fine.

These tutorials are very good: http://www.asp.net/Learn/mvc/
 
Can you give me a little review of MVC? I can see the appeal, but I was going to wait till it was a bit more mature before I went head first in.

Hopefully the above will help you too.

Essentially MVC is all about separating your code from other bits of code, so you don't end up with a completely mangled application which is hard to upgrade in the future.

So that this means in the case of ASP.NET (although not always) is that you create classes for each of your 'top level' URLs, i.e.:

Blog class:
http://127.0.0.1/blog/
http://127.0.0.1/blog/new
http://127.0.0.1/blog/archive

News class:
http://127.0.0.1/news/
http://127.0.0.1/news/new

Your blog class has three functions:
index()
new()
archive()

And the news class two:
index()
new()

So when a user accesses a particular function in the controller the controller tells ASP which view (the pages' template containing HTML) to load, and passes it any data (from the model, i.e. in the blog archive we want to go off and grab from the database all the previous blog posts) it needs to display the page.

It really means that you can re-design the layout of your site or the data it uses with minimal fuss and makes the whole site easier to manage.

It's also probably much easier than I've explained :p.
 
Cool thanks for that. So do you think you will be sticking with the MCV model for now? not going back to web apps?
 
I think so. I can do everything I normally would but much more easily. Coupled with master pages (to apply a template to the whole site) I'm sold :D.

I will point out that I've only been using it for a couple of weeks so the learning curve really isn't that steep and the http://asp.net/mvc articles are good.
 
I think so. I can do everything I normally would but much more easily. Coupled with master pages (to apply a template to the whole site) I'm sold :D.

I will point out that I've only been using it for a couple of weeks so the learning curve really isn't that steep and the http://asp.net/mvc articles are good.

I notice that you also know PHP. Was PHP your first programming language? I moved from Classic ASP to PHP to .NET (1 month ago) and love the whole visual studio thing, and it looks like MVC will be the solution to the annoyances in normal .net programming.
 
For web applications yeah I started with PHP. I then got forced into ASP/ASP.NET when I started my job as that's what everything was written in but as it happens ASP.NET seems much better than PHP.
 
Back
Top Bottom