views:

237

answers:

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?

+1  A: 

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

AndreasKnudsen
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
A: 

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.

Steve Cooper