Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it correct to say that an ASP .NET MVC application is an HTTPModule?

I just wanted to clarify my understanding of ASP .NET MVC (current version is 4).

I was reading this article on How does ASP.NET MVC work?

So, how does ASP.NET know how to route requests to MVC? The answer lies in web.config. There is a new http module added to modules collection in ASP.NET MVC projects

So basically an mvc application is implemented as an HTTPModule or at least the url routing portion of an mvc app?

Would it be possible for one to create and register a custom routing module and then possibly create their own micro mvc framework like Sinatra in Ruby or Slim in PHP?

like image 321
stormwild Avatar asked Oct 04 '22 15:10

stormwild


1 Answers

The Url routing is in fact it's own ASP.NET module. It's used both for MVC and WebForms (and can be used for other ASP.NET application types too). The routing is included in the System.Web assembly. More info about the routing features can be found at MSDN.

MVC is implemented using a IHttpHandler. The implementation can be found here.

Now for the actual question:

Would it be possible for one to create and register a custom routing module and then possibly create their own micro mvc framework like Sinatra in Ruby or Slim in PHP?

Yes. It's fully possible. You need to create your own class that implements IRouteHandler. Then simply register routes using that handler.

like image 92
jgauffin Avatar answered Oct 07 '22 18:10

jgauffin