URL http://localhost:52974/App/Detail/23432 . I know that the following code can get ID (23432), and it can be used in javascript code embedded in the cshtml file.
@ViewContext.RouteData.Values["id"]
However, I have an external jQuery script file that processes the document.ready function. The following approach will not work, because it is not a cshtml file. What is the best approach to get the MVC route id value besides using javascript to parse the url?
$(document).ready(function () { var id = @ViewContext.RouteData.Values["id"];
jquery asp.net-mvc-3
ca9163d9
source share