Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Attribute based routing is not working
Prafulla Sahu
Jan 3 2018 9:31 AM
132
Reply
Hi I have created a small demo application to test Attribute based routing but no luck till now. Need some suggestions.
Route.config class
public
class
RouteConfig
{
public
static
void
RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute(
"{resource}.axd/{*pathInfo}"
);
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name:
"Default"
,
url:
"{controller}/{action}/{id}"
,
defaults:
new
{ controller =
"Home"
, action =
"Index"
, id = UrlParameter.Optional }
);
}
}
TestingController
public
class
TestingController : Controller
{
// GET: Testing
[Route(
"demo"
)]
public
ActionResult Index()
{
return
View();
}
public
ActionResult products()
{
return
Content(
"All products"
);
}
}
This is a simple demo program only but banging my head to figure out why it is not working.
For your reference I am using visual studio 2015.
http://localhost:1352/Testing/products:
This one is working
http://localhost:1352/Testing/demo :
This one is not working
Please suggest something.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
ASP.NET MVC 5 : System.ArgumentNullException on DropDownList
How to Insert all countries names with their values into DB