Question

On my RouteConfig, I have Controller and Action name placed on the Default Route.

                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Controller", action = "Index", id = UrlParameter.Optional }               
                );           

While in page load, now the path is just 'http://geomig.com/'.

Is it possible to display full path, means 'http://geomig.com/Controller/Index' on page load.

Please help me.

Was it helpful?

Solution

You need rewrite the path using RewritePath() method.

Use the following link to know how RewritePath() works:

RewritePath

Example:

string originalPath = HttpContext.Current.Request.Path.ToLower();
if (originalPath == "/")
    Context.RewritePath("/Home/Index");

OTHER TIPS

Remove the controller and action defaults. Simply have

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { id = UrlParameter.Optional }                                    
            );     
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top