Solved

Mvc Url

Posted on 2014-01-20
6
305 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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