English 中文(简体)
资源不能在URL routing 4.0中找到。
原标题:The resource cannot be found in URL routing 4.0

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.

最佳回答

I have found the solutions, this happen with me because my application name have the ., I am using the website and the name of the website is xyz.web, when I have convert xyz.web to xyz it works for me.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签