0

I'm working on a project using MVC-5. when i run my application, I'm getting this URL: http://192.169.235.120/home/home , but i want it to be like this: http://192.169.235.120/home

so is this possible in MVC-5

11
  • you have a home folder inside a home folder? Commented Jul 25, 2017 at 12:05
  • you made a view called home , inside the home controller? Commented Jul 25, 2017 at 12:06
  • @Syfer No. we don't have home folder inside a home folder Commented Jul 25, 2017 at 12:07
  • @Ahmad Yes. we made a view called home Commented Jul 25, 2017 at 12:07
  • yeah that's why you're getting this @ashish Commented Jul 25, 2017 at 12:08

2 Answers 2

3

You could either change the route as stated in Ahmad's answer or rename your action to Index. MVC automatically routes to http://{host}/ControllerName/ActionName; in your case this seems to be the action "Home" on controller "Home". Rename your action "Home" to "Index" and you'll be able to acces http://{host}/Home, don't forget to rename your view as well.

Sign up to request clarification or add additional context in comments.

Comments

0

You should map new route in the Global.asax or RouteConfig.cs if you're using MVC 4, (add it before the default one), for example:

routes.MapRoute("SpecificRoute", "{action}/{id}", new {controller = "MyController", action = "Index", id = UrlParameter.Optional});

// default route
routes.MapRoute("Default", "{controller}/{action}/{id}", new {controller = "Home", action = "Index", id = UrlParameter.Optional} );

Hope this is helpful :)

Comments

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.