MVC - WebApi Route , RoutePrefix
MVC - WebApi Route , RoutePrefix:
Added Namespace :
using System.Web.Routing;
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//);
}
Contoller RoutePrefix :
http://localhost:1234/users/10/profile
[RoutePrefix("users/{user_id:long}/profile")]
public dynamic Get(long user_id)
{
....
....
}
Contoller Route :
http://localhost:1234/users/10/profile/2 2-Status
[Route("{Isstatus:int}")]
public dynamic put(long user_id, int status)
{
.....
}
Contoller Route :
http://localhost:1234/users/Search/aaa
[Route("users/Search/{keyword}")]
public dynamic Get(string keyword)
{
.....
}
No comments:
Post a Comment