Asp.net MVC1 在我Views/home/Index.aspx
從http://localhost/DefectSeverityAssessmentMvcBeta/
爲什麼Response.Write呈現但Html.ActionLink不?
路線這使得
Response.Write("<a href=\"");
Response.Write(Url.Action("Create", "Registration"));
Response.Write("\">Begin Registration</a>");
但對於鏈接http://localhost/DefectSeverityAssessmentMvcBeta/Registration/Create
的地址返回一個404雖然這並不呈現或顯示查看源代碼但不會導致任何異常:
Html.ActionLink("Begin Registration", "Create", "Registration");
我有一個RegistrationController和一個/Views/Registration/Create.aspx
註冊控制器在Index()和Create()上有斷點,但它們沒有被命中。
我不知道我怎麼會在這種情況下使用<%= %>
,因爲它下面的代碼塊中:
<% if (ViewData.ContainsKey("user"))
{
if (ViewData.ContainsKey("registered") && (bool)ViewData["registered"] == true)
{
//Html.RouteLink("Resume Assessment", "Assessment", new { controller = "Assessment", action = "Index" });
Response.Write("<a href=\"");
// Html.ActionLink("Resume Assessment", "Index", "Assessment");
Response.Write("\">Resume Assessment</a>");
}
else
{
//Html.RouteLink("Begin", "Registration", new { controller = "Registration", action = "Edit" });
// Html.ActionLink("Begin Registration", "Create", "Registration");
Html.RouteLink("Begin", "Default", new { controller = "Registration", action = "Edit" });
//Response.Write("<a href=\"");
//Response.Write(Url.Action("Create", "Registration"));
//Response.Write("\">Begin Registration</a>");
}
}
else
{ Response.Write("Authentication failed"); }
%>
有趣的是,他說第一種方式產生的鏈接返回404。我不知道路線是否存在? – 2009-11-25 16:53:16
不應該屬於默認路由嗎?它的形式/控制器/行動 – Maslow 2009-11-25 16:56:07