我有一个 ASP.NET Web 表单项目,具有以下路线。这通常工作正常,但我不能让最后一个工作:
static void RegisterRoutes(RouteCollection routes)
{
RouteTable.Routes.Ignore("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("Sidevisning",
"{" + Utils.Constants.RouteVariables.Article + "}",
"~/ArticleLayout.aspx");
routes.MapPageRoute("Tags",
"tags/{" + Utils.Constants.RouteVariables.Tags + "}",
"~/TagsPage.aspx");
routes.MapPageRoute("Forumpost",
"forums/topic/{" + Utils.Constants.RouteVariables.Post + "}",
"~/ForumPost.aspx");
routes.MapPageRoute("Bruger",
"users/{" +
Utils.Constants.RouteVariables.UserProfileId + "}",
"~/UserProfile.aspx");
routes.MapPageRoute("Offer",
"offers/{" + Utils.Constants.RouteVariables.OfferForm + "}",
"~/Offer.aspx");
routes.MapPageRoute("Ret opgaver",
"assignments/{" + Utils.Constants.RouteVariables.Assignment + "}",
"~/ReviewAssignments.aspx");
routes.MapPageRoute("Tutoring with subject",
"tutoring/{" + Utils.Constants.RouteVariables.TutorSubject + "}",
"~/tutoring/tutors.aspx");
routes.MapPageRoute("Tutoring with subject and city",
"tutoring/{" + Utils.Constants.RouteVariables.TutorSubject + "}/{" + Utils.Constants.RouteVariables.TutorCity + "}",
"~/tutoring/tutors.aspx");
routes.MapPageRoute("Tutoring with subject, city and level",
"tutoring/{" + Utils.Constants.RouteVariables.TutorSubject + "}/{" + Utils.Constants.RouteVariables.TutorCity + "}/{" + Utils.Constants.RouteVariables.TutorLevel + "}",
"~/tutoring/tutors.aspx");
routes.MapPageRoute("Blog kategori",
"category/{BlogCategoryName}",
"~/BlogCategory.aspx");
// be careful to switch around , it might give some pretty fucked up errors
routes.MapPageRoute("Laes Blog",
"{Year}/{Month}/{BlogHeadline}",
"~/ReadBlogEntry.aspx");
routes.MapPageRoute("Subject details",
"subject/{" + Utils.Constants.RouteVariables.SubjectChosen + "}/{" + Utils.Constants.RouteVariables.SubjectAction + "}",
"~/SubjectDetails.aspx");
}
因此,当我输入 URL 时,例如:
http://localhost:5744/subject/danskundervisning/articleoverview
我想点击 SubjectDetails.aspx。
然而,相反,我点击了其他页面并重定向到我的首页。我也找不到我正在点击的页面,这有点烦人。
从这些稀疏的信息中,我的路线是否有问题?当我输入我写的 URL 时,最后一个不应该工作吗?
我认为它没有任何兴趣,但这是我的 RouteVaraibles:
public class RouteVariables
{
public const string Article = "article";
public const string OfferForm = "offers";
public const string Forumcategory = "forumname";
public const string Post = "posturl";
public const string UserProfileId = "userid";
public const string UserProfileProfilename = "userprofilename";
public const string Tags = "tags";
public const string Assignment = "assignment";
public const string TutorSubject = "tutorsubject";
public const string TutorCity = "tutorcity";
public const string TutorLevel = "tutorlevel";
public const string SubjectAction = "subjectionaction";
public const string SubjectChosen = "subjectchosen";
}