Solved

Mvc Url

Posted on 2014-01-20
6
307 Views
Last Modified: 2014-01-22
Hi

I am using mvc , in the browser i don't want to show

any controller and action name ,I just want to show

only domain name as follows

http://localhost:3579/

I don't want to show as follow

http://localhost:3579/abc/getData

Is it possible, if so, please guide me

           Many thanks
0
Comment
Question by:praveen1981
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 39796263
Put the abc get data into your home controller index action, if you look at your roots confit it should be the default controller and action so when you hit the domain without any relative URL then it will pickup the defaults
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39796270
Hi,

This is more a bit of an example of what dean said:

Go to your App_Start folder and open RouteConfig.cs:

Find the code for a route with a name "Default" or create one and use the following code:

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

Open in new window


Now, each time you go to your domain ("http://localhost:3579/") you will get the action getData of the controller abc.

Giannis
0
 

Author Comment

by:praveen1981
ID: 39796369
Hi,

I know that what you said, it will work only initially at

the time of application is loading, but after loading

the user will do different actions, for example, the user

will click button for submitting data, or the user will click

on link to get or post data, so, what ever the action it

may be i don't want to show the controller and action name in the

url which displays in the browser

 so, please suggest.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 500 total points
ID: 39796536
I know that solutions like using angular may help, in which case your url would look always as:

http://localhost:3579/#

but this may lead to a totally different implementation of your site, which might be a huge overhead if you are not at the start of creating it.

In the standard MVC implementation, you would need to differentiate somehow between controllers and actions, and that cannot happen using the url you suggest.

So, i would suggest, either use Angular (you may check my answer here for a sample implementation).

Giannis
0
 

Author Closing Comment

by:praveen1981
ID: 39796814
Thanks for your suggestion
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 39802236
Hi I would be cautious of using angular to solve this issue, angular is client side eg JavaScript within the browser, you are actually having issues dealing with routing on the server side, so if you starting using angular you would most likely be communicating with web API, and If you are not sure how Mvc routing works well your back to square one. Ps angular is a great tool especially when it comes to unit testing your JavaScript as an added bonus!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question