我有一個CodesController和索引行動看起來像這樣。jQuery,Razor,Variables,URLs ...如何使用@ Url.Action
public ActionResult Index(int id, string manufacturerName)
我想要的網址看起來像http://www.domain.com/codes/[id]/[manufacturerName]但我目前使用的代碼它原來的樣子http://www.domain.com/codes/[id]?manufacturerName=[manufacturerName]
<script type="text/javascript">
$(function() {
$('#btnNext').click(function() {
var _id = $('#ddlManufacturers').val();
var _manufacturerName = $('#ddlManufacturers').text();
var url = '@Url.Action("Index", "Codes", new { id = "_id", manufacturerName = "_manufacturerName" })'
.replace('_id', _id).replace('_manufacturerName', _manufacturerName.toLowerCase().trim());
window.location.href = url;
});
});
這是我怎麼現在不知道這樣做如何正確地做這樣的URL證明我想要的方式。該代碼