1

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.

1
  • 1
    You need to have some kind of URL rewrite. Or have another action as a default and then redirect to the actual action method. Commented Apr 3, 2014 at 4:36

2 Answers 2

1

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");
Sign up to request clarification or add additional context in comments.

Comments

0

Remove the controller and action defaults. Simply have

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

4 Comments

In this no controller name and action specified. then mvc knows to go to a page ? .I tried this, it gives me error page
Hi @SlightlyMoist , if you remove the default controller and action name then you have type complete url . What if I what to call action just by typing the domain like 'geomig.com' in this case ?
@Raju , If you remove the default controller name and action name you have type complete url i.e 'geomig.com/Controller/Index'. For your problem you need an other action which redirects to current default action as "Nilesh" said.
Yes, I really thanks you guys for helping me. I just used another action and then did the redirection. It worked for me. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.