【问题标题】:The resource cannot be found in URL routing 4.0在 URL 路由 4.0 中找不到资源
【发布时间】:2011-10-18 10:37:42
【问题描述】:

我在我的项目中使用 URL 路由 4.0。 它给了我找不到资源,当我在单独的测试项目中使用所有相同的方法时,它工作正常,但不适用于我的实际项目。

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]*$"}});}

我在 global.aspx 中的应用程序启动时调用上述方法 下面是生成链接的方法。

    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);
    }

谁能帮我找出我在哪里做错了。 或者如何调试所有进程。

【问题讨论】:

  • 您必须至少发布一些代码才能获得帮助...
  • 好的,但是当我使用测试项目时,我的相同代码正在运行。
  • 我应该说什么 - 我手边没有水晶球
  • 只需编辑您的问题并添加您的代码,其他人可以找到问题所在

标签: c# asp.net routing


【解决方案1】:

我找到了解决方案,这发生在我身上,因为我的应用程序名称有 ., 我正在使用该网站,网站名称是 xyz.web,当我将 xyz.web 转换为 xyz 时,它对我有用.

【讨论】:

    猜你喜欢
    • 2017-02-19
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 2019-02-20
    • 2013-11-28
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多