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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dilshad AliPosted Apr 16, 2014, 4:47 AM
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.
Dilshad AliPosted Apr 16, 2014, 4:12 AM
Jignesh TrivediPosted Apr 14, 2014, 8:59 AM
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.
akshat goelPosted Apr 14, 2014, 4:36 AM
Just make the following changes
url: "ShoppingBazar/{controller}/{action}/{id}",
Dilshad AliPosted Apr 14, 2014, 3:53 AM
akshat goelPosted Apr 13, 2014, 3:09 PM
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 AliPosted Apr 13, 2014, 1:31 PM
akshat goelPosted Apr 12, 2014, 3:36 PM
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..