Archive for May, 2012

ASP.NET MVC Application Execution Process

May 30, 2012 4 comments

Stage Details
Receive first request for the application In the Global.asax file, Route objects are
added to the  RouteTable object.
Perform routing The UrlRoutingModule module uses the first matching Route object in the RouteTable collection to create the
object, which it then uses to create a
Create MVC request handler The MvcRouteHandler object creates an instance of the MvcHandler class and passes the RequestContext instance to the handler.
Create controller The MvcHandler object uses the RequestContext instance to identify the IControllerFactory object (typically an instance of the DefaultControllerFactory class) to create the controller
instance with.
Execute controller The MvcHandler instance calls the controller’s
Invoke action For controllers that inherit from the ControllerBase class, the ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and then calls that method.
Execute result The action method receives user input, prepares the appropriate response data, and then executes the result by returning a result type. The built-in result types that
can be executed include the following: ViewResult (which renders a view and is the most-often used result
type), RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult, and EmptyResult.

Request.ApplicationPath is not working

Sometime Request.ApplicationPath  does not work with all browser properly  , so use this.Request.Url.GetLeftPart(UriPartial.Authority) instead.

Lets get it by example:

If we use Request.ApplicationPath‘” + Request.ApplicationPath + “/Massimo/ProductDetails.aspx”‘);
It will be rendered as http://Massimo/ProductDetails.aspx that i do not want

If we use Request.Url.GetLeftPart(UriPartial.Authority)

then it will be rendered as  http://ServerName/Massimo/ProductDetails.aspx that is what we want.

I hope it will be helpful in your problem , if it help you ,give give Comment that make me post more solution of day to day problem occurred in our programming life.

Categories: ASP.NET Tags:
%d bloggers like this: