• 0

[ASP.NET] Baisc questions about ASP.NET


Question

Hello. I have learnt some basic skills in Java EE (such as JSP, Servlet, TagLib, JavaBeans and EJB), and now I want to learn something about .NET platform. Since I am going to learn ASP.NET in next semester in school, I wish to self-study it before attend lessons.

Before self-study ASP.NET, I have questions about it:

1. Does ASP.NET have MVC concept? In Java EE, M (Model) is JavaBeans, V (View) is JSP, C (Controller) is Servlet.

2. Comparing to JSP in Java EE, ASP.NET has ASPX, so what are equivalent technologies in ASP.NET comparing to servlet and TagLib in Java EE?

Thank you very much. :)

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
Hello. I have learnt some basic skills in Java EE (such as JSP, Servlet, TagLib, JavaBeans and EJB), and now I want to learn something about .NET platform. Since I am going to learn ASP.NET in next semester in school, I wish to self-study it before attend lessons.

Before self-study ASP.NET, I have questions about it:

1. Does ASP.NET have MVC concept? In Java EE, M (Model) is JavaBeans, V (View) is JSP, C (Controller) is Servlet.

2. Comparing to JSP in Java EE, ASP.NET has ASPX, so what are equivalent technologies in ASP.NET comparing to servlet and TagLib in Java EE?

Thank you very much. :)

Hope this helps.

1. http://www.asp.net/mvc/

Link to comment
Share on other sites

  • 0

Hi GraphiteCube,

1. As still1 has mentioned, ASP.NET MVC is a relatively new framework built on ASP.NET that enforces a strong MVC model. I've been expanding on this a lot recently, so if you have any questions, let me know.

With ASP.NET MVC, you can create a Controller class, e.g:

public AccountController : Controller {
  public ActionResult Login() {
	...
  }
  ...
}

What the MVC Framework will do, is (using the Routing classes provided by System.Web.Routing) maps a route from a url to a controller. E.g. mydomain.com/Account/Login can be mapped to the AccountController controller type, executing the method Login(). This is all very transparent to the developer (unless you wanted to get nitty-gritty with the plumbing (like I do ;))).

The model is any data you want to pass to a view. Typically you'd return from the Login() function with any type that inherits from ActionResult, commonly through the View() function:

public ActionResult Login() {
  return View();
}

What the View() function will do, is return a ViewResult which instructs the framework to locate the View with the name Login from the view repository folder, e.g. /Views/Account/Login.aspx, passing it any model data you wanted to.

There is a hell of a lot more we can talk about, but thats the basics of it, you can get a whole load of info from http://www.asp.net.

2. What a Servlet does in Java is that it receives a request, and returns a response. ASP.NET has the same concept, and its called a Http Handler. When a request is making its way through the ASP.NET pipeline, it will end up at a handler, which implements IHttpHandler. Standard ASP.NET pages (.aspx) do the same thing, everything does really, ASP.NET MVC pages get processed by the MvcHttpHandler, etc. Technologies such as webforms and mvc kinda hide the necessity for a custom handler, as they can pretty much do everything anyway. It would depend on the specific scenario of what you want to achieve, as to what route to take.

Tag Libraries in java don't have a direct counterpart in most ASP.NET projects. In classic WebForms (and also somewhat in MVC) we can express custom tags in our pages, which will get processed server side. Typically this is for custom controls, e.g.

namespace Test {
  public SomeControl : WebControl {
	public string Text { get; set; }
  }
}

<%@ Register TagPrefix="my" Namespace="Test" Assembly="TestAssembly" %>
...
<my:SomeControl runat="server" Text="Here is some text" />

All of the ASP.NET controls which exist in the standard installation (from the Base Class Library) are registered either in the page, or in a configuration file. Expanding on this is relatively easy.

I hope that answers some of your questions, let me know if you have any more.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.