I am using URL routing 4.0 in my project. It gives me The resource cannot be found, when I am using all same methods in separate test project that works fine, but not with my actual project.
public static void SetUpRoutes(RouteCollection routes)
{
// Add StopRoutingHandler for .axd and .asmx requests
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.Ignore("{service}.asmx/{*pathInfo}");
routes.MapPageRoute("AllAssignment", "questions/", "~/Questions/default.aspx");
routes.MapPageRoute("AllAssignmentQuestions", "questions/AllQuestionAssignment/{pageno}",
"~/Questions/assignments.aspx", true, new RouteValueDictionary {{"pageno", null}},
new RouteValueDictionary {{"pageno", @"^[0-9]*$"}});}
I am calling above method on application start in global.aspx below are the methods for generating link.
private static string GetEntityURL(string routeName, RouteValueDictionary parameters)
{
VirtualPathData entity = null;
entity = RouteTable.Routes.GetVirtualPath(null, routeName, parameters);
if (entity != null) return string.Format("{0}", entity.VirtualPath);
return null;
}
public static string GetAllAssignmentQuestionsURL()
{
RouteValueDictionary parameters = new RouteValueDictionary();
return GetEntityURL("AllAssignmentQuestions", parameters);
}
can any one help me to find out where I am doing mistake. OR how can I debug all the process.