asp.net mvc - I need to take the controller action's name out of the URL, but don't know how -


this question has answer here:

example: view contract id of 12483, use url:

/contract/12483  

i can't in asp.net mvc because asp.net route exepects /{controller}/{action}/{id} able route needed code handle request have this:

/contract/view/12483  

this not restful, however.

anyone know way around this?

one option can use name of actionresult index instead of view.

or can use in app_start/routeconfig.cs

routes.maproute(     name: "book",     url: "{controller}/{id}",     defaults: new { controller = "contract", action = "view", id = urlparameter.optional }); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -