Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mvc Url

Posted on 2014-01-20
6
Medium Priority
?
312 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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