2

I'm getting a strange error in my MVC site. I have an action in my controller which responds to the default route of {controller}/{action}/{id} - in my case, /Project/Client/{id}.

Depending on the id I pass to it, I get an error. With Elmah off, it's a straight-up ASP.NET 404 error. Turning Elmah on gives me the following:

System.Web.HttpException
   at System.Web.CachedPathData.GetConfigPathData(String configPath)
   at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
   at System.Web.HttpContext.GetFilePathData()
   at System.Web.HttpContext.GetConfigurationPathData()
   at System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context)
   at System.Web.HttpContext.get_ImpersonationToken()
   at System.Web.ClientImpersonationContext.Start(HttpContext context, Boolean throwOnError)
   at System.Web.HttpApplication.ThreadContext.SetImpersonationContext()
   at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext)
   at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
   at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)

This only happens with certain ID params. for example

/Projects/Client/ABC -- works
/Projects/Client/DEF -- works
/Projects/Client/GHI -- 404
/Projects/Client/JKL -- works

and so on...

Any clues?

3
  • Do you have any other routes set up in your application? Jun 4, 2009 at 9:01
  • I have one that also adds a page param, so {controller}/{action}/{id}/{page}
    – Chris
    Jun 4, 2009 at 9:30
  • Do you have a unit test for the "GHI" example? It would help to be sure that you really have a routing problem and not a problem in the Controller logic.
    – Jim Counts
    Jun 30, 2009 at 16:38

3 Answers 3

1

You can use Phil Haacks route debugger to learn which routes are being called read here: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

1
  • This didn't uncover any problems, but it introduced me to a nifty new tool that solved a problem in another project, so awarding the answer to you, in absence of any better solutions.
    – Chris
    Jul 30, 2009 at 8:19
0

One thing you should look at is your web.config files in your site. The top of your stack trace;

at System.Web.CachedPathData.GetConfigPathData(String configPath)

Looks to be a call to determine the location of the web.config. It may be that the virtual file system being defined by your routes (/Project/client/id) is conflicting with a web.config that may exist at, say, ~/Project/web.config

It's a bit of a wild stab derived from the stack trace, but shouldn't take too long to see if it might be a problem.

0

In case anyone else shows up on this page and doesn't find the solution they are looking for, certain character strings are not allowed in URLs. Read about it here:

Weird 404 error in ASP.NET MVC when including "con"

The solution is another of Microsoft's "WorkProperly" flags (whose default value is "false")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.