我有一个动作
public class EmployerController : Controller
{
public ActionResult Message(string contractorId, int projectId)
{....}
和 @html.ActionLink 作为
@Html.ActionLink("Message", "Message", "Employer", new { contractorId = @model.ContractorId, projectId = @model.ProjectId }, null)
我最终得到了像这样的网址
http://localhost:3597/Employer/Message?contractorId=contractor&projectId=10
而我想要像这样的网址
http://localhost:3597/Employer/Message/contractor/10
在我的 RouteConfig.cs 中,我添加了
routes.MapRoute(
name: "MessageRoute",
url: "Employer/Message/{contractorId}/{projectId}",
defaults: new { controller = "Employer", action = "Message", contractorId = (string)null, projectId = 0 }
);
我错过了什么。如何禁用路由中的查询字符串?
/谢谢。