Solved

Mvc Url

Posted on 2014-01-20
6
302 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Combine two columns 3 37
What are the big features of MVC5? 4 50
IIs block files web.config 6 73
How do I get the id from URL? 19 47
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now