次のルートを持つ 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";
}