Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mvc Url

Posted on 2014-01-20
6
Medium Priority
?
311 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
Independent Software Vendors: 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 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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