I want to show my custom Url in MVC 4 using razor.
Default Url
http://localhost:58276/Home/
and i want custom Url
http://localhost:58276/ShoppingBazar/
plz help me over come
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
akshat goel39 reputationPosted Apr 12, 2014, 11:36 AM EDT
If we recall http://localhost:58276/Home/
Here Home is the controller.
Now if you want to make ShoppingBazar as your default url, You would need to edit the RouteConfig.cs file which is available in the app_start folder.
In the routeconfig file you would find some code like this:
The highlighted "Home" tells the compiler that your default controller class is home.. Change it to ShoppingBazaar..
Dilshad AliRank #1,926 · 762 reputationPosted Apr 13, 2014, 9:31 AM EDT
akshat goel39 reputationPosted Apr 13, 2014, 11:09 AM EDT
click on + against App_Start folder in solution explorer..
Open the RouteConfig.cs file....
Change the "Home" as shown in the code above to ShoppingBazar....
Just make sure that you have a controller named ShoppingBazar otherwise it will show a error....
Your code will look something like this..
If your query is solved.. mark the reply as answer...
Dilshad AliRank #1,926 · 762 reputationPosted Apr 13, 2014, 11:53 PM EDT
akshat goel39 reputationPosted Apr 14, 2014, 12:36 AM EDT
Just make the following changes
url: "ShoppingBazar/{controller}/{action}/{id}",
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 14, 2014, 4:59 AM EDT
Add following route in route dictionary in Global.asax.
routes.MapRoute(
"Default", // Route name
"ShoppingBazar/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
hope this help you.
Dilshad AliRank #1,926 · 762 reputationPosted Apr 16, 2014, 12:12 AM EDT
Dilshad AliRank #1,926 · 762 reputationPosted Apr 16, 2014, 12:47 AM EDT
In View to redirect a page
----------------------------
@Html.RouteLink("About", "MyFeature")
In RouteConfig class to url route page
---------------------------------------
routes.MapRoute(
name: "MyFeature",
url: "Custom Name/Custom Name",
defaults: new { controller = "Home", action = "About", id = UrlParameter.Optional } );
Once again I extremely thank C-sharpcorner platform.