How does IIS recognize that request is for MVC Controllers or webforms Pages? - asp.net-mvc

When the Application pool receives a request, it simply passes the request to worker process (w3wp.exe) . The worker process “w3wp.exe” looks up the URL of the request in order to load the correct ISAPI extension. ISAPI extensions are the IIS way to handle requests for different resources. Once ASP.NET is installed, it installs its own ISAPI extension (aspnet_isapi.dll) and adds the mapping into IIS.
Si If that's true, my question is how does it recognize which extensions to be loaded
for that request?? MVC / Web Forms?
When and where does the IIS come to know that a request is for MVC or WebForms Application?
How framework decide which Modules should handle the request and decide to render page content or views in MVC.

hen and were the IIS come to know that request is for MVC or WebForms Application?
They are both ASP.NET applications so it doesn't need to recognize that. The aspnet_isapi.dll is perfectly capable of serving both types of applications (which are actually a single type called ASP.NET).
ASP.NET MVC is just a custom handler added to the ASP.NET pipeline.

That all is about the standard IHttpModule and IHttpHandler infrastructure. See complete description here Routing with ASP.NET Web Forms and here How ASP.NET MVC Routing Works and its Impact on the Performance of Static Requests

Related

asp.net mvc routing depending on session

I have an ASP.Net MVC site and I want that every request to images of my site
/images/image_name.png
are redirected to
/images/{skin}/image_name.png
where {skin} is session dependant.
and I would like to make the same for any type of files (css, some json file for configurations,...)
I was asking if it is possible in ASP.Net MVC to hook requests at HttpListener level to make there the correct switch depending on the session.
Thanks a lot

ColdFusion/ASP split URL handling

I am working on a new ASP.NET MVC (IIS 7) application that needs to hang off the URL of an existing group of ColdFusion applications. The URL hosts a series of applications and is of the form:
http://myapps.com/allApps/<appNumber>/<appViews>
ColdFusion is currently handling all the applications on this URL. I need the new ASP.NET application to use the same URL format but have a specific <appNumber>. So for example, ColdFusion handles:
http://myapps.com/allApps/1/<appViews>
http://myapps.com/allApps/2/<appViews>
http://myapps.com/allApps/3/<appViews>
http://myapps.com/allApps/4/<appViews>
New ASP.NET app needs to handle:
http://myapps.com/allApps/5/<appViews>
I know how to use ASP routing to send the requests to my ASP app controller once my app is getting the requests, but I don't know how to tell IIS to send the specific URLs to my application so they are not processed by ColdFusion.
Unless you have IIS set up to pass ASP.NET pages to ColdFusion for processing, it should not matter.

What's the advantage of ASP.NET Web API to ASP.NET MVC Controller?

What's the advantage of ASP.NET Web API to ASP.NET MVC Controller?
As far as I know, IIS + WebDAV conflicts with ASP.NET Web API while using "PUT" verb[1].
We can use ASP.NET MVC Controller & JsonResult, etc. to communicate with clients, which use HTTP GET+POST and no more verb to get better compatibility, so what's the advantage of ASP.NET Web API to ASP.NET MVC?
And, ASP.NET Web API should only use the desigend teens HTTP verbs. If I'd like to develop a Web API to let a robot JUMP, but JUMP is not a standard HTTP verb. So how to design the url? http://localhost/api/robot/jump ? But it is not RESTful(RESTful urls should not contain verb).
reference:
[1] http://forums.iis.net/t/1163441.aspx
If you are asking about the difference between Asp.Net application .cs files and controllers in MVC.
We can navigate to required method in MVC depending upon requirement but this is not possible in Asp.Net web.
Always, firing the page load event will not happen.
We can return partial results/Json results/Javascript results and so on.
Unlike Asp.Net life cycle, MVC has its own page life cycle.
Regards,
Pavan.G

Is it possible to host an ASP.NET MVC2 website from a windows service?

I have a .NET 4 application that runs as a windows service. It runs periodic tasks and provides WCF restful webservices. It already hosts a silverlight web page (via WCF) that allows a user to configure the service.
Now I have a requirement to provide information on HTML/java script pages (e.g. for browsers and platforms that don't support Silverlight). I can serve simple HTML and javascript pages through WCF but that becomes laborious very quickly. I'd like to use MVC2.
Is it possible to provide MVC2 web pages from within a windows service? Or at least use some of the functionality provided by MVC like routing and the view engine?
Or is it more trouble than it's worth and should I head down the path of a separate app hosted on IIS?
You can host the ASP.NET runtime in any type of application including a Windows Service using the CreateApplicationHost method. Although note that by doing this you lose the robustness, security, logging, etc... that a real web server such as IIS provides.
Since you're asking the question about what route to take, I'd host an MVC2 application in IIS. Why recreate a web server using WCF when IIS is already there - and since you're asking, it sounds like that's a viable option.
I agree with Darin's answer that you can host ASP.NET MVC2 in any application, but I think you're going to end up recreating a lot of plumbing that's already in place with IIS.
On the upside, if you go with serving up ASP.NET MVC2 resources in a WCF service application, it may end up rocking and you could have a nice application you can sell on the side. :)

Which's the best performance between Asp.net MVC controller VS. Wcf for Silverlight Application?

I found that Asp.net Mvc controller can serve both Asp.net Mvc View and Silverlight application via DynamicActionResult(It can be Simple Action Result or Json Action Result depend on request type). So, I have 3 options for creating middle-tier for Silverlight application.
Pure WCF Service Every request to WCF must be declare in interface. So, it's strongly-typed connection.
Asp.net MVC Controller It can serve both Asp.net MVC View and Silverlight application at the same time.
Using both of them I found that it's possible to doing this by using the answer in the following link. I think, It doesn't good idea for creating both of them.
WCF Service with Asp.net MVC application
Which's the best performance between WCF Service and Asp.net MVC Controller?
Thanks,
Do you have the kind of service that would benefit from caching? If so, my testing says that MVC with Output Caching turned on is very much faster than WCF.

Resources